Overview

Packages

  • Mnemo
  • None

Classes

  • Mnemo
  • Mnemo_Ajax_Application
  • Mnemo_Ajax_Imple_EditNote
  • Mnemo_Api
  • Mnemo_Driver
  • Mnemo_Driver_Kolab
  • Mnemo_Driver_Sql
  • Mnemo_Exception
  • Mnemo_Factory_Driver
  • Mnemo_Factory_Notepads
  • Mnemo_Form_CreateNotepad
  • Mnemo_Form_DeleteNotepad
  • Mnemo_Form_EditNotepad
  • Mnemo_Notepads_Base
  • Mnemo_Notepads_Default
  • Mnemo_Notepads_Kolab
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * The base functionality of the notepads handler.
 4:  *
 5:  * PHP version 5
 6:  *
 7:  * @category Horde
 8:  * @package  Mnemo
 9:  * @author   Jon Parise <jon@horde.org>
10:  * @author   Gunnar Wrobel <wrobel@pardus.de>
11:  * @license  http://www.horde.org/licenses/apache
12:  * @link     http://www.horde.org/apps/mnemo
13:  */
14: 
15: /**
16:  * The base functionality of the notepads handler.
17:  *
18:  * Copyright 2001-2012 Horde LLC (http://www.horde.org/)
19:  *
20:  * See the enclosed file LICENSE for license information (ASL). If you
21:  * did not receive this file, see http://www.horde.org/licenses/apache.
22:  *
23:  * @category Horde
24:  * @package  Mnemo
25:  * @author   Jon Parise <jon@horde.org>
26:  * @author   Gunnar Wrobel <wrobel@pardus.de>
27:  * @license  http://www.horde.org/licenses/apache
28:  * @link     http://www.horde.org/apps/mnemo
29:  */
30: abstract class Mnemo_Notepads_Base
31: {
32:     /**
33:      * The share backend.
34:      *
35:      * @var Horde_Share_Base
36:      */
37:     protected $shares;
38: 
39:     /**
40:      * The current user.
41:      *
42:      * @var string
43:      */
44:     protected $user;
45: 
46:     /**
47:      * Additional parameters for the notepad handling.
48:      *
49:      * @var array
50:      */
51:     protected $params;
52: 
53:     /**
54:      * Constructor.
55:      *
56:      * @param Horde_Share_Base $shares The share backend.
57:      * @param string           $user   The current user.
58:      * @param array            $params Additional parameters.
59:      */
60:     public function __construct($shares, $user, $params)
61:     {
62:         $this->shares = $shares;
63:         $this->user = $user;
64:         $this->params = $params;
65:     }
66: 
67:     /**
68:      * Ensure the share system has a default notepad share for the current user
69:      * if the default share feature is activated.
70:      *
71:      * @return string|NULL The id of the new default share or NULL if no share
72:      *                     was created.
73:      */
74:     public function ensureDefaultShare()
75:     {
76:         /* If the user doesn't own a task list, create one. */
77:         if (!empty($this->params['auto_create']) && $this->user &&
78:             !count(Mnemo::listNotepads(true))) {
79:             $share = $this->shares->newShare(
80:                 $this->user,
81:                 strval(new Horde_Support_Randomid()),
82:                 $this->getDefaultShareName()
83:             );
84:             $this->shares->addShare($share);
85:             return $share->getName();
86:         }
87:     }
88: 
89:     /**
90:      * Return the name of the default share.
91:      *
92:      * @return string The name of a default share.
93:      */
94:     abstract protected function getDefaultShareName();
95: }
API documentation generated by ApiGen