gosa-plugin-groupware-2.7.4/0000755000175000017500000000000011752422556014767 5ustar cajuscajusgosa-plugin-groupware-2.7.4/contrib/0000755000175000017500000000000011752422556016427 5ustar cajuscajusgosa-plugin-groupware-2.7.4/html/0000755000175000017500000000000011752422556015733 5ustar cajuscajusgosa-plugin-groupware-2.7.4/html/images/0000755000175000017500000000000011752422556017200 5ustar cajuscajusgosa-plugin-groupware-2.7.4/html/images/plugin.png0000644000175000017500000000167311474700320021200 0ustar cajuscajus‰PNG  IHDR00`Ü µsBITÛáOà pHYs11·í(RtEXtSoftwarewww.inkscape.org›î<hPLTEÿÿÿlšÒz¤Ö§Ø¨Ø‚©Ø±Ú³Ý’³Ý“µÞ˜¸ßš¸Ü›ºàœ¹Ûž¼ß ¾â¡½à£Àã§Áá¨Ãä«Äà«Å嬯å¯Èæ°Æà°Éç±Éç²Èã²Êç¶Éâ¸Îé¸Ïé¼Ñë½Ñè½Ñë¾Òë¿ÓìÀÒçÀÓëÁÔéÁÔëÁÔìÄÔçÄ×íÅ×íÆ×íÆ×îÇÔæÇÙîÈÙîÉÙîÊÚïËÙëÍÜîÏÛçÏÝðÏÞðÑßñÒàñÓàñÔâòÖâðÖâò×áîØäóÙäòÙåóÙåôÚáêÚãíÛæôÜæóÝäìÞãêÞèõßéõàéôáèòáêõâëöäìöåíöåî÷æî÷çîøçï÷èëîèï÷éîôéðøìïóìòùíòùîñôîóúïôúòõøòöûó÷ûõøúõøü÷úýøùúøúüøúýùûýúüýüýþýýýýþþýþÿþþÿÿÿÿžŽ“tRNSDgh'Åþr±IDATxÚí”Ù[aG³+[”²¦RD’5•L"Z´ ²"Ê”¥æßoðb„Œ‹®rn¾÷y~çÜ~Sþ*4Ô†Oa°Hàà‰‘†IÃ:+OÖϳèÍÀü £¬mZ¢_£ô¯¨es ³Y¯Û}þÝÞÕéÍfÇΪêà}¸þ~ ZÝÁ5öXË‘ÏÁúgdYamJ5ñnH´™A~F+Ùð¶ŽCµÐôöS3 Õ‡m‚“®…Y_¨×}³ ®îÁ=î¡ë?ÌñõÄ‚‘S9WœméY1W~Ú3BpK$°ÈLÛ«VµO x‹ž‚=ÑÒyÌ8ùºâÌcçK¢=â Á}‡øúüÖþF¥l¶4Šw[óëñîÁc›k,g0G@¦¹îdDiHdúH”Hû† ß$ë^AòAVÜÙÖÁKƒÔövê¥ŸÞ ‚Wœ›¿ø:”¢ßvÓx!@ÑRØ“F%í —P‚J!tQªŒ t*T È]>Uë#©>]æ H–1R”“Ô0’Ô ÀHƒãþ|cÿ­cÿÞþ ߊ^¸\ŸIEND®B`‚gosa-plugin-groupware-2.7.4/plugin.dsc0000644000175000017500000000040311437135125016746 0ustar cajuscajus[gosa-plugin] name = groupware description = "Groupware management base plugin" version = 2.7 author = "Fabian Hickert " maintainer = "GOsa packages maintainers group " homepage = https://oss.gonicus.de/labs/gosa/ gosa-plugin-groupware-2.7.4/etc/0000755000175000017500000000000011752422556015542 5ustar cajuscajusgosa-plugin-groupware-2.7.4/personal/0000755000175000017500000000000011752422556016612 5ustar cajuscajusgosa-plugin-groupware-2.7.4/personal/groupware/0000755000175000017500000000000011752422556020625 5ustar cajuscajusgosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/0000755000175000017500000000000011752422556023204 5ustar cajuscajusgosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/class_FolderEditDialog.inc0000644000175000017500000000656511456026176030240 0ustar cajuscajusconfig = $config; $this->folderItem = $folderItem; $this->isNew = $isNew; // Prepare new item if($this->isNew){ $entry = array(); $entry['name'] = ""; $entry['acls'] = array(); $this->folderItem = $entry; } } function setPermissions($perms) { $this->permissions = $perms; } function execute() { $smarty = get_smarty(); // Prepare folder name and path $smarty->assign('folderName', preg_replace("/\{%cn\}/", "Group name", $this->folderItem['name'])); if(isset($this->folderItem['path'])){ $smarty->assign('folderPath', preg_replace("/\{%cn\}/", "Group name", $this->folderItem['path'])); }else{ $smarty->assign('folderPath', ''); } $smarty->assign('folderItem', $this->folderItem); $smarty->assign('permissions', $this->permissions); $smarty->assign('permissionCnt', count($this->permissions)); $smarty->assign('isNew', $this->isNew); return($smarty->fetch(get_template_path("FolderEditDialog.tpl", TRUE, dirname(__FILE__)))); } function save_object() { // Get folder name if($this->is_new){ if(isset($_POST['folderName'])){ $this->folderItem['name'] = get_post('folderName'); } } // Get all posted value modifications foreach($this->folderItem['acls'] as $id => $aclEntry){ // Name or ACL modified? if(isset($_POST["permission_{$id}_name"])) { $name = get_post("permission_{$id}_name"); $this->folderItem['acls'][$id]['name'] = get_post("permission_{$id}_name"); } if(isset($_POST["permission_{$id}_acl"])) { $this->folderItem['acls'][$id]['acl'] = get_post("permission_{$id}_acl"); } // Check if entry has to be removed. if(isset($_POST["permission_{$id}_del"])){ unset($this->folderItem['acls'][$id]); } } // New ACL entry to add? if(isset($_POST['permission_add'])){ $this->folderItem['acls'][] = array('name' => '', 'acl' => 0, 'type' => 'user'); } $this->folderItem['acls'] = array_values($this->folderItem['acls']); } function isNew() { return($this->isNew); } function check() { $message = array(); // Check if we've duplicate ACL definitions for a user $aclNames = array(); foreach($this->folderItem['acls'] as $entry){ if(!isset($aclNames[$entry['name']])){ $aclNames[$entry['name']] = TRUE; }elseif(!empty($entry['name'])){ $message[] = sprintf(_("Duplicate permission setting for user '%s'."), $entry['name']); } } return($message); } function save() { // Remove empty ACL defintions foreach($this->folderItem['acls'] as $id => $entry){ if(empty($entry['name'])) unset($this->folderItem['acls'][$id]); } return($this->folderItem); } } ?> gosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/FolderEditDialog.tpl0000644000175000017500000000331711455314222027060 0ustar cajuscajus {if $isNew}

{t}Create folder{/t}

{t}Name{/t}: 
{else}

{t}Edit folder{/t}

{t}Name{/t}:  {$folderName}
{t}Path{/t}:  {$folderPath}
{/if}

{t}Permissions{/t}

{foreach from=$folderItem.acls item=item key=key} {/foreach}
{t}Type{/t} {t}Name{/t} {t}Permission{/t}
{$item.type} {if $permissionCnt == 0 || !isset($permissions[$item.acl])} {else} {/if}

gosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/class_FolderWidget.inc0000644000175000017500000003671411472477066027463 0ustar cajuscajus 1024, 'klaus' => '210'); * * // 'status' Represents the folder status, maybe it wasn't touched then status is ''; * // If the folder was added, then the status is 'added'. Status 'removed' * // handles the folder as removed. * * // 'name' Represents the entry name, this should match the name in the path. * * // 'acls' Represents ACLs set for the folder. * Syntax ['userNmae' => ACL] // See $this->setPermissions(); * * */ class FolderWidget extends plugin { public $pathTitle = "Folder editor"; public $plHeadline = "Folder editor"; private $pathSeparator = "/"; private $rootName = "/"; private $fakeCnAttr = "cn="; private $rootBase = ""; public $config; private $FolderWidgetListing = NULL; private $folderList; private $baseEntryMap = array(); private $permissions = array(); protected $displayButtons = TRUE; /*! \brief Constructs the widget and initializes all required sub-widgets. */ function __construct(&$config, $folderList, $accountPrefix) { $this->config = $config; // The rootBase is a dn-like representation of the root path // e.g. rootPath is '/' then is the rootBase 'cn=/' // These are just internally used variables and should not have an // effect on the results. $this->rootBase = $this->fakeCnAttr.$this->rootName; // Remove trailing / from accountPrefix. $this->accountPrefix = (empty($accountPrefix)) ? "" : rtrim($accountPrefix,$this->pathSeparator); $this->rootBase = $this->pathToDn($accountPrefix); // Update the folder list, initially. $this->setFolderList($folderList); $this->FolderWidgetListing = new FolderWidgetListing($this->config, get_userinfo(), $this->rootBase, $this); $this->FolderWidgetListing->setBase($this->rootBase); $this->FolderWidgetListing->setFolderRoot($this->rootBase); } function showButtons($bool = TRUE) { $this->displayButtons = $bool; } /*! \brief Updates the list of all selectable ACLs * @param Array The list of acls to use * Syntax is [ 'ACLname'] => 'diplayName', 0=>'None',1=>'Read',...] */ function setPermissions($perms) { $this->permissions = $perms; } /*! \brief The be able to use the LDAP-Based listint widget we've to create * some kind of fake dns/bases, this method converts a path to such a dn/base. * * e.g. 'shared/technik/test' will return 'cn=test,cn=technik,cn=test,cn=/'; * * @param String The path to convert * @return String The generated base. */ function pathToDn($path) { $dn ="cn=/"; $list = preg_split("/".preg_quote($this->pathSeparator,'/')."/", $path,0,PREG_SPLIT_NO_EMPTY); foreach($list as $entry){ $dn ="cn={$entry},{$dn}"; } return($dn); } /*! \brief A function to detect the folderType for a given foldePath * This folderType tells the listing widget hat images has to be used. * See: FolderWidget-list.xml */ function getFolderType($item) { if(preg_match("/^user\//", $item['path'])) return('userFolder'); if(preg_match("/^shared\//", $item['path'])) return('sharedFolder'); } /*! \brief Tell the widget which folders should be displayed. */ function setFolderList($arr) { $this->buildRecursiveList($arr, $this->pathSeparator); // Ensure that we've at least the base folder set if(!isset($this->folderList['linear'][$this->accountPrefix])){ $this->addPath($this->accountPrefix, preg_replace("/^.*\//","", $this->accountPrefix)); trigger_error(sprintf("You reuquire at least a folder named '%s'! This time it was added automatically.", $this->accountPrefix)); } } /* \brief Builds a hierarchical structure which can then be * used by the FolderWidgetListing. * * @param Array The folder list * @return Array A hierarchical representation of the input array. */ function buildRecursiveList($arr, $separator) { $data = array(); $ret = array(); // Add root Entry $data['/'] = array(); $data['/']['name'] = '/'; $data['/']['status'] = ''; $data['/']['acls'] = array(); $data['/']['path'] = '/'; $data['/']['type'] = 'manual'; $data['/']['base'] = 'cn=/'; $data['/']['parentPath'] = ""; $data['/']['children'] = array(); $this->baseEntryMap = array(); $this->baseEntryMap['cn=/'] = '/'; $this->folderList = array(); $this->folderList['linear']['/'] = &$data['/']; $this->folderList['recursive']['/'] = &$data['/']; foreach($arr as $path => $data){ $name = $data['name']; $acls = $data['acls']; $status = $data['status']; $this->addPath($path, $name, $acls, $status); } } /*! \brief Adds a new folder entry to the used folderList. */ function addPath($path, $name, $acls = array(), $status = "") { $base = &$this->folderList['linear']['/']['children']; $last = NULL; // Only add entries that match the accountPrefix // e.g. "/user/admin/" $path = rtrim($path,$this->pathSeparator); if(!preg_match("/^".preg_quote($this->accountPrefix,'/')."/", $path)){ // Skipping not mathing folders. }else{ $current = &$base; $pathSteps = preg_split("/".preg_quote($this->pathSeparator,'/')."/", $path); $entryPath = ""; $parentPath = ""; $entryBase = ""; // Walk through path entries and add missing entries to our folder list foreach($pathSteps as $pathName){ // The parent path is the last path. $parentPath = $entryPath; // Calculate entry path by combining last path and current pathName. $entryPath = (empty($entryPath)) ? $pathName : "{$entryPath}{$this->pathSeparator}{$pathName}"; $entryBase = $this->pathToDn($entryPath); // To not add sub-folders which are not nescessary to be displayed // e.g. We have shared/technik/test // Then do not all sub-folders for shared, it is not selectable in the listing later. if(!preg_match("/".preg_quote($this->accountPrefix,'/')."/", $entryPath)){ continue; } // Add eventually missing subFolders, to enable the navigation // into these folders via the management lists. if(!isset($current[$entryPath])){ $current[$entryPath] = array(); $current[$entryPath]['children'] = array(); $current[$entryPath]['name'] = $pathName; $current[$entryPath]['path'] = $entryPath; $current[$entryPath]['status'] = ''; $current[$entryPath]['acls'] = array(); $current[$entryPath]['type'] = 'manual'; $current[$entryPath]['base'] = $entryBase; $current[$entryPath]['parentPath'] = $parentPath; $current[$entryPath]['folderType'] = $this->getFolderType($current[$entryPath]); $this->folderList['linear'][$entryPath] = &$current[$entryPath]; $this->baseEntryMap[$entryBase] = $entryPath; } // Remeber the last added sub-folder and update the current folder position. $last = &$current[$entryPath]; $current = &$current[$entryPath]['children']; } // Now that we've created all subfolders we can set the folder // paramters of the folder we originally wanted to add. $last['acls'] = $acls; $last['name'] = $name; $last['type'] = 'real'; $last['status'] = $status; } } /*! \brief Initiates editing of a folder, a sub dialog will be shown on next * render() call. this sub-dialog allows to edit the ACLs for the folder. */ function editByBase($base) { $item = NULL; foreach($this->folderList['linear'] as $item){ if($item['base'] == $base){ break; } } if($item){ $this->currentlyEditedItem = $item; $this->dialog = new FolderEditDialog($this->config, $item); $this->dialog->setPermissions($this->permissions); } } function dialogOpened() { return($this->dialog != FALSE); } /*! \brief Removes a given folder, internally it is just marked with status => 'removed'; */ function removeByBase($base) { // Do not allow to remove the root base. // This would mean the account itself was removed. if($base == $this->rootBase) return; $this->_recursiveRemoveByBase($this->folderList['recursive'], $base); $this->_recursiveRemoveByBase($this->folderList['linear'], $base); $this->FolderWidgetListing->setFolderList($this->folderList); } /*! \brief Shows a sub-dialog on next render call, which allows to specify * a folder name and acls, which will then be added to the list of folders. */ function addFolder() { $this->currentlyEditedItem = NULL; $this->dialog = new FolderEditDialog($this->config, array(), TRUE); $this->dialog->setPermissions($this->permissions); } /*!\brief Recursivly removes a folder by its base. */ private function _recursiveRemoveByBase(&$arr, $base) { $ret = array(); foreach($arr as $path => $item){ if($item['base'] == $base){ // remove all children too if(isset($item['children']) && count($item['children'])){ foreach($item['children'] as $child){ $this->_recursiveRemoveByBase($this->folderList['recursive'], $child['base']); } } // Remove the the entry instead of setting its status if it was just added. if($arr[$path]['status'] == "added"){ unset($arr[$path]) ; }else{ $arr[$path]['status'] = 'removed'; } }elseif(isset($item['children']) && count($item['children'])){ $ret = array_merge($ret, $this->_recursiveRemoveByBase($arr[$path]['children'], $base)); } } return($ret); } /*!\brief Recursivly collects all folders, this is called from save(). */ private function _saveRecursive($arr) { $ret = array(); foreach($arr as $path => $item){ if($item['type'] == 'real'){ $ret[$path] = array( 'name' => $item['name'], 'status' => $item['status'], 'acls' => $item['acls'], ); } if(isset($item['children']) && count($item['children'])){ $ret = array_merge($ret, $this->_saveRecursive($item['children'])); } } return($ret); } /*! \brief Returns the folder list with all changes made during * the session. */ function save() { return($this->_saveRecursive($this->folderList['recursive'])); } /*! \brief Generates the HTML output for the current widget. * Handles add/edit dialogs too. */ function execute() { // Generate the listing output session::set('FolderWidgetListing::folderList', $this->folderList); $this->FolderWidgetListing->setFolderList($this->folderList); $smarty = get_smarty(); $smarty->assign("SHOW_BUTTONS", $this->displayButtons); $str = $this->FolderWidgetListing->execute(); if($this->dialog){ $this->dialog->save_object(); return($this->dialog->execute()); } // Return listing HTML return($str); } /*! \brief Check GET and POST for interesting informations. * Like edit request from the folder listing */ function save_object() { $this->FolderWidgetListing->save_object(); // Handle dialogs if(isset($_POST['FolderEditDialog_ok']) && is_object($this->dialog)){ $this->dialog->save_object(); $msgs = $this->dialog->check(); if(count($msgs)){ msg_dialog::displayChecks($msgs); }else{ if($this->dialog->isNew()){ // Detect the current entry $base = $this->FolderWidgetListing->getBase(); if(isset($this->baseEntryMap[$base])){ $entry = $this->folderList['linear'][$this->baseEntryMap[$base]]; $path = $entry['path']; $newItem = $this->dialog->save(); $name = $newItem['name']; $newPath = rtrim($path,$this->pathSeparator).$this->pathSeparator.$name; $newItem['status'] = 'added'; $newItem['type'] = 'real'; $newItem['children'] = array(); $newItem['path'] = $newPath; $newItem['parentPath'] = $entry['path']; $newItem['folderType'] = $this->getFolderType($newItem); $newItem['base'] = $this->pathToDn($newPath); $this->folderList['linear'][$path]['children'][$newPath] = $newItem; $this->folderList['linear'][$newPath] = &$this->folderList['linear'][$path]['children'][$newPath]; $this->baseEntryMap[$newItem['base']] = $newPath; } }else{ $newItem = $this->dialog->save(); $path = $this->currentlyEditedItem['path']; $this->folderList['linear'][$path]['acls'] = $newItem['acls']; } $this->dialog = NULL; } } if(isset($_POST['FolderEditDialog_cancel'])){ $this->dialog = NULL; } } } ?> gosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/FolderWidget-list.tpl0000644000175000017500000000120211464232552027243 0ustar cajuscajus

{$HEADLINE} {$SIZELIMIT}

{$RELOAD} {t}Basis{/t}: {$RELEASE} {$ACTIONS} {$FILTER}
{$LIST}
{if $SHOW_BUTTONS}
{/if} gosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/FolderWidget-list.xml0000644000175000017500000000471211456013462027253 0ustar cajuscajus false false false true users 1 FAKE_OC_Groupware_sharedFolder images/lists/folder.png FAKE_OC_Groupware_userFolder plugins/users/images/select_user.png |20px;c||170px;r| %{filter:objectType(dn,objectClass)} cn string %{filter:link(row,cn,"%s",cn)} true %{filter:actions(dn,row,objectClass)}
sub images/lists/element.png[new] new entry images/lists/folder.png separator remove entry images/lists/trash.png exporter editEntry entry images/lists/edit.png remove entry images/lists/trash.png
gosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/class_filterFolderWidget.inc0000644000175000017500000000413411471227462030650 0ustar cajuscajus 1); $entry[] = 'cn'; $entry['folderType'] = array($item['folderType'], 'count' => 1); $entry[] = 'folderType'; $entry['objectClass'] = array('FAKE_OC_Groupware_'.$item['folderType'],'count' => 1); $entry[] = 'objectClass'; $entry['count'] = 4; $ret[] = $entry; } if($recursive && isset($item['children']) && count($item['children'])){ foreach($item['children'] as $item){ filterFolderWidget::addEntry($ret, $item, $recursive,$filter); } } } } ?> gosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/FolderWidget-filter.xml0000644000175000017500000000104711453350512027560 0ustar cajuscajus Groupware true default auto - default FolderWidget $ cn 0.5 3 gosa-plugin-groupware-2.7.4/personal/groupware/FolderWidget/class_FolderWidgetListing.inc0000644000175000017500000001001011461213363030754 0ustar cajuscajusconfig = $config; $this->ui = $ui; $this->storagePoints = array(""); $this->rootBase = $rootBase; $this->parent = &$parent; // Build filter if (FALSE && session::global_is_set(get_class($this)."_filter")){ $filter= session::global_get(get_class($this)."_filter"); } else { $filter = new filter(get_template_path("FolderWidget-filter.xml", true, dirname(__FILE__))); $filter->setObjectStorage($this->storagePoints); } $this->setFilter($filter); // Build headpage $headpage = new listing(get_template_path("FolderWidget-list.xml", true, dirname(__FILE__))); $headpage->setFilter($filter); $headpage->setBase($this->rootBase); // Create folderSelector using dummy entries, those will be replaced // once setFolderList is called. $this->folderSelector = new releaseSelector(array($this->rootBase => '/'),$this->rootBase,$this->rootBase); parent::__construct($config, $ui, "Folder", $headpage); // Register default actions $this->registerAction("new", "newEntry"); $this->registerAction("edit", "openEntry"); // !! We forward 'edit' to 'open' to have a department like navigation. $this->registerAction("editEntry", "editEntry"); } function openEntry($action, $targets) { $this->setBase($targets[0]); } function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { $this->parent->editByBase($target[0]); } function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { $this->parent->addFolder(); } protected function removeEntryRequested($action="",$target=array(),$all=array()) { foreach($target as $tar){ $this->parent->removeByBase($tar); if($tar == $this->base) $this->setBase($this->rootBase); } } function setFolderList($folderList) { $this->folderList = $folderList; } function getBase() { return($this->base); } function setBase($base) { $this->base = $base; $this->folderSelector->setBase($this->base); $headpage = $this->getHeadpage(); $headpage->setBase($this->base); } function setFolderRoot($base) { $this->rootBase = $base; $this->folderSelector->setRootBase($base); } /*! \brief Overridden render method of class mangement. * this allows us to add a release selection box. */ function renderList() { $this->folderSelector->setBases($this->getSimpleFolderList($this->folderList['recursive']['/']['children'])); $this->folderSelector->update(true); $headpage = $this->getHeadpage(); $headpage->update(); $smarty = get_smarty(); $smarty->assign("RELEASE", $this->folderSelector->render()); $display = $headpage->render(); return($this->getHeader().$display); } function getSimpleFolderList($arr) { $ret = array($this->rootBase => '/'); foreach($arr as $path => $entry){ if($entry['status'] != 'removed'){ $ret[$entry['base']] = $entry['name']; if(isset($entry['children'])){ $ret = array_merge($ret, $this->getSimpleFolderList($entry['children'])); } } } return($ret); } function save_object() { $this->folderSelector->update(); $this->setBase($this->folderSelector->getBase()); } } ?> gosa-plugin-groupware-2.7.4/personal/groupware/class_FilterEditor.inc0000644000175000017500000001731711613742614025106 0ustar cajuscajusconfig = &$config; $this->parent = &$parent; $this->filter = $filter; $this->types = array( 'OR' => _("At least one of the following conditions has to match"), 'AND' => _("All conditions have to match")); $this->actions = array( "MOVE" => _("move mail to"), "COPY" => _("copy mail to"), "FORWARD" => _("forward message to"), "MARK" => _("mark mail as "), "DROP" => _("remove mail"), "REPLY" => _("reply")); $this->fields = array( 'subject' => _("Subject"), 'from'=> _("From"), 'body'=> _("Body"), 'date'=> _("Date"), 'priority'=> _("Priority"), 'status'=> _("Status"), 'to'=> _("To"), 'cc'=> _("CC"), 'age'=> _("Age"), 'size'=> _("Size")); $this->comparators = array( "is" => _("is"), "is not" => _("is not"), "equal" => _("is equal"), "not equal" => _("is not equal"), "is empty" => _("is empty"), "is not empty" => _("is not empty"), "contains" => _("contains"), "contains not" => _("does not contain"), "is in addressbook" => _("is in the addressbook"), "is not in addressbook" => _("is not in the addressbook"), "greater than" => _("is greater than"), "less than" => _("smaller than")); } function execute() { $smarty = get_smarty(); $smarty->assign('NAME',set_post($this->filter['NAME'])); $smarty->assign('DESC',set_post($this->filter['DESC'])); $smarty->assign('filterStr', $this->renderFilter()); $smarty->assign('acl', $this->parent->getacl('mailFilter')); return($smarty->fetch(get_template_path('filterEditor.tpl',TRUE,dirname(__FILE__)))); } function check() { $msgs = array(); return($msgs); } function save() { // Just return the filter array we've modified return($this->filter); } function renderFilter() { $filter = $this->filter; $cnt = count($filter['CONDITIONS']); $str = "

"._("Filter conditions")."

"; $str .= _("Condition type")." "; $str .="\n"; $str.= "
    "; foreach($filter['CONDITIONS'] as $id => $cond){ $str .= "
  • "; # $str .= _("Check field")." "; $str .= "\n"; # $str .= " "._("if it")." "; $str .= "\n "; if(!in_array_strict($cond['COMPARATOR'], array('is in addressbook','is not in addressbook','is empty','is not empty'))){ $str .= ""; } if(count($filter['CONDITIONS']) >= 2){ $str .= " "; } $cnt --; $str .= "
  • "; # if($cnt) $str .= $this->types[$filter['TYPE']]; } $str .= "
"; $str .= " "; $str .= "
"; $str .= "

"._("Filter actions")."

"; $str.= "
    "; foreach($filter['ACTION'] as $id => $action){ $str .= "
  • "; $str .= "\n "; if(!in_array_strict($action['ACTION'], array('DROP'))){ $str .= ""; } if(count($filter['ACTION']) >= 2){ $str .= ""; } $str .= "
  • "; } $str.= "
"; $str .= " "; return($str); } function save_object() { // Do nothing if the dialog wasn't submitted yet if(!isset($_POST['filterEditorPosted'])) return; // Get the filter confition type if posted $this->filter['TYPE'] = (isset($_POST['cType']))? get_post('cType'): $this->filter['TYPE']; // Get condition modifications foreach($this->filter['CONDITIONS'] as $id => $value){ foreach(array('cField_' => 'FIELD', 'cComparator_'=>'COMPARATOR', 'cMatch_'=>'MATCH') as $post => $name){ if(isset($_POST[$post.$id])){ $this->filter['CONDITIONS'][$id][$name] = get_post($post.$id); } } if(isset($_POST['removeCondition_'.$id]) && count($this->filter['CONDITIONS']) >= 2){ unset($this->filter['CONDITIONS'][$id]); } } // Get Action modifications foreach($this->filter['ACTION'] as $id => $value){ foreach(array('cAction_' => 'ACTIOB','cValue_' => 'VALUE') as $post => $name){ if(isset($_POST[$post.$id])){ $this->filter['ACTION'][$id][$name] = get_post($post.$id); } } if(isset($_POST['removeAction_'.$id]) && count($this->filter['ACTION']) >= 2){ unset($this->filter['ACTION'][$id]); } } // Get NAME and DESC if posted if(isset($_POST['NAME'])) $this->filter['NAME'] = get_post('NAME'); if(isset($_POST['DESC'])) $this->filter['DESC'] = get_post('DESC'); // Add conditions if(isset($_POST['addCondition'])){ $this->filter['CONDITIONS'][] = array('FIELD' => key($this->fields),'COMPARATOR' => key($this->comparators), 'MATCH' => ''); } // Add actions if(isset($_POST['addAction'])){ $this->filter['ACTION'][] = array('ACTION' => 'MOVE', 'VALUE' => ''); } } } ?> gosa-plugin-groupware-2.7.4/personal/groupware/class_GroupwareDefinitions.inc0000644000175000017500000000457011473446267026667 0ustar cajuscajus gosa-plugin-groupware-2.7.4/personal/groupware/class_FilterManager.inc0000644000175000017500000001252711471244767025240 0ustar cajuscajusparent = &$parent; $this->filter = $rules; // If we've read permissions then allow to edit the entries $acl = $this->parent->getacl('mailFilter'); $acl = preg_replace("/r/","rw", $acl); $this->filterListing= new sortableListing(); $this->filterListing->setDeleteable(TRUE); $this->filterListing->setEditable(TRUE); $this->filterListing->setColspecs(array('*')); $this->filterListing->setWidth("100%"); $this->filterListing->setHeight("150px;"); $this->filterListing->setAcl($acl); $this->filterListing->setColspecs(array('30px','200px','*')); $this->filterListing->setHeader(array('-',_("Name"),_("Description"))); $this->filterListing->setDefaultSortColumn(1); } function execute() { // If we've read permissions then allow to edit the entries $acl = $this->parent->getacl('mailFilter'); $acl = preg_replace("/r/","rw", $acl); $this->filterListing->setAcl($acl); // Display filter editor while a filter rule is edited if($this->filterEditor instanceOf FilterEditor){ $this->filterEditor->save_object(); return($this->filterEditor->execute()); } $smarty = get_smarty(); $data = $lData = array(); foreach($this->filter as $key => $filter){ $data[$key] = $filter; switch($filter['STATUS']){ case 'NEW' : $img = image('images/lists/edit.png[new]');break; case 'MODIFIED' : $img = image('images/lists/edit.png');break; case 'EXISTS' : $img = image('images/lists/edit.png');break; default : $img = ""; } $lData[$key] = array('data' => array($img,$filter['NAME'], $filter['DESC'])); } $this->filterListing->setListData($data,$lData); $this->filterListing->update(); $smarty->assign('acl', $this->parent->getacl('mailFilter')); $smarty->assign('list', $this->filterListing->render()); return($smarty->fetch(get_template_path('filterManager.tpl',TRUE,dirname(__FILE__)))); } function save_object() { $this->filterListing->save_object(); $action = $this->filterListing->getAction(); // Remove filter was requested. if($action['action'] == 'delete'){ $key = $action['targets'][0]; $key = $this->filterListing->getKey($key); if(isset($this->filter[$key])){ unset($this->filter[$key]); $this->filter = array_values($this->filter); } } // Edit filter was requested. if($action['action'] == 'edit'){ $key = $action['targets'][0]; $key = $this->filterListing->getKey($key); if(isset($this->filter[$key])){ $filter = $this->filter[$key]; $this->filterEditor = new FilterEditor($this->config,$this->parent, $filter); $this->currentFilter = $key; } } // Add new filter if(isset($_POST['addFilter'])){ $filter = array ( 'STATUS' => 'NEW', 'TYPE' => 'AND', 'NAME' => _('name'), 'DESC' => _('description'), 'CONDITIONS' => array ( array('FIELD' => 'from', 'COMPARATOR' => 'equals', 'MATCH' => 'example@domain.com'), array('FIELD' => 'subject', 'COMPARATOR' => 'contains', 'MATCH' => _('advertising')), ), 'ACTION' => array ( array('ACTION'=>'MARK', 'VALUE' => 'SPAM'), array('ACTION'=>'MOVE', 'VALUE' => '') ) ); $this->filterEditor = new FilterEditor($this->config,$this->parent, $filter); } // Close filter editor if(isset($_POST['filterEditor_cancel']) && $this->filterEditor instanceOf FilterEditor){ $this->currentFilter = NULL; $this->filterEditor = NULL; } // Save filter modifications and close the dialog if(isset($_POST['filterEditor_ok']) && $this->filterEditor instanceOf FilterEditor){ $this->filterEditor->save_object(); $msgs = $this->filterEditor->check(); if(count($msgs)){ msg_dialog::displayChecks($msgs); }else{ $filter = $this->filterEditor->save(); if($filter['STATUS'] == 'NEW'){ $this->filter[] = $filter; }else{ if($filter['STATUS'] != 'NEW') $filter['STATUS'] = 'MODIFIED'; $this->filter[$this->currentFilter] = $filter; } $this->filterEditor = NULL; $this->currentFilter = NULL; } } } function save() { return($this->filter); } } ?> gosa-plugin-groupware-2.7.4/personal/groupware/generic.tpl0000644000175000017500000003553311461267142022766 0ustar cajuscajus{if $initFailed}

{t}Communication with backend failed, please check the rpc connection and try again!{/t}

{elseif $rpcError}

{t}Communication with backend failed, please check the rpc connection and try again!{/t}

{else} {if !$alternateAddresses_isActive} {else} {/if}

{t}Generic{/t}

{if $mailLocations_isActive} {/if} {if $mailFolder_isActive} {/if} {if $quotaUsage_isActive} {/if} {if $quotaSize_isActive} {/if} {if $mailFilter_isActive} {/if}
{$must} {render acl=$mailAddressACL} {/render}
{render acl=$mailLocationACL} {/render}
{if $uid == ""} {t}Can only be set for existing accounts!{/t} {else} {render acl=$mailFolderACL} {/render} {/if}
{render acl=$quotaUsageACL} {/render}
{render acl=$quotaSizeACL} MB {/render}
{render acl=$mailFilterACL mode=read_active} {/render}
 

{render acl=$alternateAddressesACL}
{/render} {render acl=$alternateAddressesACL} {/render} {render acl=$alternateAddressesACL} {/render} {render acl=$alternateAddressesACL} {/render}
{if $vacationMessage_isActive || $forwardingAddresses_isActive}
{if !$forwardingAddresses_isActive} {else} {/if}
{if $vacationMessage_isActive}

{render acl=$vacationEnabledACL} {/render} {t}Activate vacation message{/t}
{render acl=$vacationMessageACL} {/render}
{if $displayTemplateSelector eq "true"} {render acl=$vacationMessageACL} {/render} {render acl=$vacationMessageACL} {/render} {/if}
{/if}
 

{render acl=$forwardingAddressesACL} {/render}
{render acl=$forwardingAddressesACL} {/render} {render acl=$forwardingAddressesACL}   {/render} {render acl=$forwardingAddressesACL}   {/render} {render acl=$forwardingAddressesACL} {/render}
{/if} {* Do not render the Flag list while there are none! *} {if $mailBoxWarnLimit_isActive || $mailBoxSendSizelimit_isActive || $mailBoxHardSizelimit_isActive || $mailBoxAutomaticRemoval_isActive || $localDeliveryOnly_isActive || $dropOwnMails_isActive}

{t}Mailbox options{/t}

{if $mailBoxWarnLimit_isActive} {/if} {if $mailBoxSendSizelimit_isActive} {/if} {if $mailBoxHardSizelimit_isActive} {/if} {if $mailBoxAutomaticRemoval_isActive} {/if} {if $mailLimit_isActive} {/if} {if $localDeliveryOnly_isActive} {/if} {if $dropOwnMails_isActive} {/if}
{render acl=$mailBoxWarnLimitACL} {/render} {render acl=$mailBoxWarnLimitACL} {t}MB{/t} {/render}
{render acl=$mailBoxSendSizelimitACL} {/render} {render acl=$mailBoxSendSizelimitACL} {t}MB{/t} {/render}
{render acl=$mailBoxHardSizelimitACL} {/render} {render acl=$mailBoxHardSizelimitACL} {t}MB{/t} {/render}
{render acl=$mailBoxAutomaticRemovalACL} {/render} {render acl=$mailBoxAutomaticRemovalACL} {t}days{/t} {/render}
{t}kbyte{/t}
{t}kbyte{/t}
{render acl=$localDeliveryOnlyACL} {/render} {t}User is only allowed to send and receive local mails{/t}
{render acl=$dropOwnMailsACL} {/render} {t}No delivery to own mailbox{/t}
{/if} {/if} gosa-plugin-groupware-2.7.4/personal/groupware/filterEditor.tpl0000644000175000017500000000163611441424003023770 0ustar cajuscajus

{t}Filter editor{/t}

: {render acl=$acl} {/render}
{render acl=$acl} {/render}

{render acl=$acl} {$filterStr} {/render}
{render acl=$acl} {/render}
gosa-plugin-groupware-2.7.4/personal/groupware/class_GroupwareDao.inc0000644000175000017500000003476211473446267025125 0ustar cajuscajus array( "get"=>"gwAcctGetPrimaryMailAddress", "save"=>"gwAcctSetPrimaryMailAddress"), "mailLocations" => array("get"=>"gwGetMailboxLocations"), "quotaSize" =>array( "get"=>"gwAcctGetQuota", "save"=>"gwAcctSetQuota", "delete"=>"gwAcctSetQuota"), "mailFilter" =>array( "get"=>"gwAcctGetFilters", "save"=>"gwAcctSetFilters", "delete"=>"gwAcctDelFilter"), "alternateAddresses" =>array( "get"=>"gwAcctGetAlternateMailAddresses", "save"=>"gwAcctSetAlternateMailAddresses", "delete"=>"gwAcctDelAlternateMailAddress"), "forwardingAddresses" =>array( "get"=>"gwAcctGetMailForwardAddresses", "save"=>"gwAcctSetMailForwardAddresses", "delete"=>"gwAcctDelMailForwardAddress"), "vacationMessage" =>array( "get"=>"gwAcctGetOutOfOfficeReply", "save"=>"gwAcctSetOutOfOfficeReply", "delete"=>"gwAcctDelOutOfOfficeReply"), "mailBoxWarnLimit" =>array( "get"=>"", "save"=>"", "delete"=>""), "mailBoxSendSizelimit" =>array( "get"=>"gwAcctGetQuota", "save"=>"gwAcctSetQuota", "delete"=>"gwAcctDelQuota"), "mailBoxHardSizelimit" =>array( "get"=>"gwAcctGetMailLimit", "save"=>"gwAcctSetMailLimit", "delete"=>"gwAcctDelMailLimit"), "mailBoxAutomaticRemoval" =>array( "get"=>"", "save"=>"", "delete"=>""), "localDeliveryOnly" =>array( "get"=>"", "save"=>"", "delete"=>""), "dropOwnMails" =>array( "get"=>"", "save"=>"", "delete"=>""), "accountProperties" => array("get"=>"gwAcctGetProperties", "save"=>"gwAcctSetProperties", "delete"=>"gwAcctDelProperties"), //mailFolder is a composite feature - "mailFolder" => array( "get"=>"gwFolderList", "save"=>"gwFolderAdd", "delete"=>"gwFolderDel"), "private_folderACLS" => array("get"=>"gwFolderGetMembers", "save"=>"gwFolderSetMembers", "delete"=>"gwFolderDelMember"), "mailLimit" => array("get"=>"gwAcctGetMailLimit", "save"=>"gwAcctSetMailLimit"), //function for speedup "folderListWithMembers" => array( "get"=>"gwFolderListWithMembers"), "comprehensiveUser" => array( "get"=>'gwAcctGetComprehensiveUser'), "folderACLs" => array( "get"=>'gwFolderGetMember', "save"=>'gwFolderSetMembers') ); /*! \brief Constructor sets the connection to the rpc service * initializes the class */ function __construct(&$pluginRef) { $this->groupwarePluginRef = &$pluginRef; $this->init(); } /*! \brief Gets the capabilities of the server * builds an array with availbale features and knows how to call get, save, delete functions of * groupware rpc. */ public function init() { $this->availableMethods = $this->groupwarePluginRef->rpcExec('gwGetCapabilities'); } /*! \brief Generic saving method for all features defined in $gwFeatures * which are the available features. */ public function save($feature, $uid, $valueArray = null) { $function = GroupwareDao::$gwFeatures[$feature]["save"]; if(is_array($valueArray)){ $valueArray = array_merge(array($function, $uid), $valueArray); }else{ if(!empty($valueArray)){ //add if single value $valueArray = array($function, $uid, $valueArray); } else{ //omit otherwise $valueArray = array($function, $uid); } } //TODO: Remove the debug output //echo "----call_user_func_array:
";
		//var_dump($valueArray);
		//echo "
"; $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); return $result; } /*! \brief generic get method for all features defined in $gwFeatures * which are the available features. */ public function get($feature, $valueArray) { $function = GroupwareDao::$gwFeatures[$feature]["get"]; if(is_array($valueArray)){ $valueArray = array_merge(array($function), $valueArray); }else{ $valueArray = array($function, $valueArray); } $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); return $result; } /*! \brief generic delete function for all features defined in $gwFeatures * which are the available features. * * NOT YET IMPLEMENTED */ public function del($feature, $uid, $valueArray = "") { //just debugs echo "Feature:".$feature; echo "uid:".$uid; echo "array:".$valueArray; $function = GroupwareDao::$gwFeatures[$feature]["delete"]; if(is_array($valueArray)){ //merge if array $valueArray = array_merge(array($function, $uid), $valueArray); }else{ if(!empty($valueArray)){ //add if single value $valueArray = array($function, $uid, $valueArray); } else{ //omit otherwise $valueArray = array($function, $uid); } } $result = call_user_func_array(array($this->groupwarePluginRef, 'rpcExec'), $valueArray); return $result; } /*! \brief determine availability of features. * * @param methodName * @return boolean */ public function gwFeatureAvailable($methodName) { return(isset($this->availableMethods[$methodName]) && ($this->availableMethods[$methodName])); } /*! \brief comprehensive user info will dessolve into one groupware call later * right now it will get all data of the features that are available in the plugin. * @param int $uid * @return assoc array "feature" => "gwValue"; */ public function getComprehensiverUser( $uid) { if($this->groupwarePluginRef->isFeatureEnabled("comprehensiveUser")){ return $this->getComprehensiverUserCompact($uid); } else{ return $this->getComprehensiverUserSeparate($uid); } } private function getComprehensiverUserCompact($uid){ $resultArr = array(); if($this->groupwarePluginRef->isFeatureEnabled("mailLocations")){ $resultArr["mailLocations"] = $this->groupwarePluginRef->rpcExec('gwGetMailboxLocations'); } $comp = $this->get("comprehensiveUser", array($uid)); $resultArr["primaryMail"] = $comp["primaryMail"]; $resultArr["alternateAddresses"] = $comp["alternateAddresses"]; //This dao will only accept the first forwardingAddress. $resultArr["forwardingAddresses"] = array(key($comp["forwardingAddresses"])); var_dump($resultArr["forwardingAddresses"]); $resultArr["mailLocation"] = $comp["mailLocation"]; //Quota things. $resultArr["quotaSize"] = $comp["quota"]["usage"]; if(!empty($comp["quota"]["warn_limit"])){ $resultArr["mailBoxWarnLimitEnabled"] = TRUE; } else{ $resultArr["mailBoxWarnLimitEnabled"] = FALSE; } $resultArr["mailBoxWarnLimitValue"] = $comp["quota"]["warn_limit"]; if(!empty($comp["quota"]["send_limit"])){ $resultArr["mailBoxSendSizelimitEnabled"] = TRUE; } else{ $resultArr["mailBoxSendSizelimitEnabled"] = FALSE; } $resultArr["mailBoxSendSizelimitValue"] = $comp["quota"]["send_limit"]; if(!empty($comp["quota"]["hard_limit"])){ $resultArr["mailBoxHardSizelimitEnabled"] = TRUE; } else{ $resultArr["mailBoxHardSizelimitEnabled"] = FALSE; } $resultArr["mailBoxHardSizelimitValue"] = $comp["quota"]["hard_limit"]; //Mail Limits if(!empty($comp["mailLimits"]["receive"])){ $resultArr["mailLimitReceiveEnabled"] = TRUE; } else{ $resultArr["mailLimitReceiveEnabled"] = FALSE; } $resultArr["mailLimitReceiveValue"] = $comp["mailLimits"]["receive"]; if(!empty($comp["mailLimits"]["send"])){ $resultArr["mailLimitSendEnabled"] = TRUE; } else{ $resultArr["mailLimitSendEnabled"] = FALSE; } $resultArr["mailLimitSendValue"] = $comp["mailLimits"]["send"]; if(empty($comp["vacation"]["message"])){ $resultArr["vacationEnabled"] = FALSE; $resultArr["vacationMessage"] = ""; } else{ $resultArr["vacationEnabled"] = TRUE; $resultArr["vacationMessage"] = $comp["vacation"]["message"]; } return $resultArr; } /* \brief Returns a list of mail folders for the current folderPrefix. * Acl entries will be returned the GOsa-usable way. * @return Array A list of mail folder entries. */ function getListOfMailFolders() { $prefix = $this->groupwarePluginRef->folderPrefix; $compFolders = $this->get("folderListWithMembers", array($prefix)); return($this->translateGwAclsToGosaAcls($compFolders)); } /* \brief Returns a list of mail folders for the current folderPrefix. * Fetches every feature data chunk seperately * @return Array A list of mail folder entries. */ private function getComprehensiverUserSeparate($uid){ if($this->groupwarePluginRef->isFeatureEnabled("primaryMail")){ $resultArr["primaryMail"] = $this->get("primaryMail", array($uid)); } if($this->groupwarePluginRef->isFeatureEnabled("alternateAddresses")){ $resultArr["alternateAddresses"] = $this->get("alternateAddresses", array($uid)); } if($this->groupwarePluginRef->isFeatureEnabled("forwardingAddresses")){ $resultArr["forwardingAddresses"] = $this->get("forwardingAddresses", array($uid)); } // Location dropdownlist - only readable if($this->groupwarePluginRef->isFeatureEnabled("mailLocations")){ $resultArr["mailLocations"] = $this->groupwarePluginRef->rpcExec('gwGetMailboxLocations'); $resultArr["mailLocation"] = $this->groupwarePluginRef->rpcExec('gwAcctGetLocation',$uid); } // Load account folders. if($this->groupwarePluginRef->isFeatureEnabled("mailFolder")){ // Get groupware folders for the current user. $prefix = $this->groupwarePluginRef->folderPrefix; $mFolder = $this->get("mailFolder", array($prefix)); $newFolder = array(); foreach($mFolder as $key =>$val){ $newFolder[$val] = $this->get("private_folderACLS", array($val)); } $resultArr["mailFolder"] = $this->translateGwAclsToGosaAcls($newFolder); // Add the required status field for each folder. foreach($resultArr["mailFolder"] as $id => $folder){ $resultArr["mailFolder"][$id]['status'] = ''; } } // Quota quotaUsage, quotaSize if($this->groupwarePluginRef->isFeatureEnabled("quotaSize") || $this->groupwarePluginRef->isFeatureEnabled("quotaUsage") || $this->groupwarePluginRef->isFeatureEnabled("mailBoxWarnLimit") || $this->groupwarePluginRef->isFeatureEnabled("mailBoxSendSizelimit") || $this->groupwarePluginRef->isFeatureEnabled("mailBoxHardSizelimit")){ // example Array for Quota $quota = $this->get("quotaSize", array($uid)); $resultArr["quotaSize"] = $quota["usage"]; $resultArr["quotaSize"] = $quota["hold"]; if($quota["warn_limit"] > 0){ $resultArr["mailBoxWarnLimitEnabled"] = TRUE; $resultArr["mailBoxWarnLimitValue"] = $quota["warn_limit"]; }else{ $resultArr["mailBoxWarnLimitEnabled"] = FALSE; } if($quota["send_limit"] > 0){ $resultArr["mailBoxSendSizelimitEnabled"] = TRUE; $resultArr["mailBoxSendSizelimitValue"] = $quota["send_limit"]; }else{ $resultArr["mailBoxSendSizelimitEnabled"] = FALSE; } if($quota["hard_limit"] > 0){ $resultArr["mailBoxHardSizelimitEnabled"] = TRUE; $resultArr["mailBoxHardSizelimitValue"] = $quota["hard_limit"]; }else{ $resultArr["mailBoxHardSizelimitEnabled"] = FALSE; } } // Load account limitations if($this->groupwarePluginRef->isFeatureEnabled("mailLimit")){ $mailLimits = $this->get("mailLimit", array($uid)); if($mailLimits["receive"] > 0){ $resultArr["mailLimitReceiveEnabled"] = TRUE; $resultArr["mailLimitReceiveValue"] = $mailLimits["receive"]; }else{ $resultArr["mailLimitReceiveEnabled"] = FALSE; } if($mailLimits["send"] > 0){ $resultArr["mailLimitSendEnabled"] = TRUE; $resultArr["mailLimitSendValue"] = $mailLimits["send"]; }else{ $resultArr["mailLimitSendEnabled"] = FALSE; } } #FIXME Validate the vacation message handling, seems to be broken on the server side. if($this->groupwarePluginRef->isFeatureEnabled("vacationMessage")){ $vacArray = $this->get("vacationMessage", array($uid)); $resultArr["vacationMessage"] = $vacArray["message"]; $resultArr["vacationEnabled"] = !empty($resultArr["vacationMessage"]); } return $resultArr; } /* \brief Translates Groupware folderAcls to Gosa widget Acls. * @return Array list of Groupware Members with rights to folders. */ private function translateGwAclsToGosaAcls($compFolders){ $resultArr = array(); foreach ($compFolders as $fName => $fMembers) { $resultArr[$fName]["name"] = preg_replace("/^.*\//","",$fName); $resultArr[$fName]["status"] = ""; $resultArr[$fName]["acls"] = array(); foreach($fMembers as $fMember => $fAcl){ $aclLine = array( "name" => $fMember, "type"=>"user" ); if(empty($fAcl)){ $aclLine["acl"] = GROUPWARE_RIGHTS_NONE; } else{ $aclLine["acl"] = $fAcl; } $resultArr[$fName]["acls"][] = $aclLine; } } return $resultArr; } } ?> gosa-plugin-groupware-2.7.4/personal/groupware/filterManager.tpl0000644000175000017500000000056711441424003024116 0ustar cajuscajus

{t}Available filter rules {/t}

{$list} {render acl=$acl} {/render}
{render acl=$acl} {/render}
gosa-plugin-groupware-2.7.4/personal/groupware/class_Groupware.inc0000644000175000017500000014732111613742614024464 0ustar cajuscajusattrs['uid'])){ $this->uid = $this->attrs['uid'][0]; } // Set initial folder prefix $this->folderPrefix = "user/{$this->uid}"; // Initialize the plugin using rpc. $this->init(); } /*! \brief Try to execute a function on the gosa backend using json-rpc. * This method also takes care about errors and sets the required * class members, such as rpcError and rpcErrorMessage. * @param String function The name of the function to call. * @param Mixed args[0-n] The parameter to use. * @return Mixed The result of the function call on success else NULL. */ function rpcExec($function) { $params = func_get_args(); unset($params[0]); $rpc = $this->config->getRpcHandle(); $res = call_user_func_array(array($rpc,$function),array_values($params)); $this->rpcError = !$rpc->success(); if($this->rpcError){ $this->rpcErrorMessage = $rpc->get_error(); return(NULL); } return($res); } /*! \brief Checks if feature is availavle on the server (a call to getCapabilities achieves this.) */ public function isFeatureEnabled($featureName) { if(!isset($this->enabledFeatures[$featureName])){ trigger_error("No such feature '{$featureName}'!"); } return(isset($this->enabledFeatures[$featureName]) && $this->enabledFeatures[$featureName]); } /*! \brief Checking if the feature has been changed since loading it from server (initial state) */ public function hasFeaturebeenChanged($featureName) { //TODO: must be implemented. return TRUE; } /*! \brief Try initialize the groupware account. * This method fetches all required information to manage the * account using the GOsa gui. */ function init() { // Detect feature availability and enable/disable services correspondingly. $this->groupwareDao = new GroupwareDao($this); // Feature names with a list of groupware functions that must be available. $features = array(); $featureReq = array( "primaryMail" => array( 'acctGetPrimaryMailAddress'), "quotaUsage" => array( 'acctGetQuota'), "quotaSize" => array( 'acctSetQuota','acctGetQuota'), "mailLocations" => array("_off", 'getMailboxLocations'), "mailFilter" => array("_off", 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'), "alternateAddresses" => array( 'acctDelAlternateMailAddress','acctSetAlternateMailAddresses', 'acctAddAlternateMailAddress','acctGetAlternateMailAddresses'), "forwardingAddresses" => array( 'acctAddMailForwardAddress','acctDelMailForwardAddress', 'acctGetMailForwardAddresses','acctSetMailForwardAddresses'), "vacationMessage" => array( 'acctSetOutOfOfficeReply', 'acctGetOutOfOfficeReply'), "mailBoxWarnLimit" => array( 'acctSetQuota','acctGetQuota'), "mailBoxSendSizelimit" => array( 'acctSetQuota','acctGetQuota'), //This is the same as qotaSize - should stay turned off "mailBoxHardSizelimit" => array("_off", 'acctSetQuota','acctGetQuota'), "mailBoxAutomaticRemoval" => array("_off", 'acctSetQuota','acctGetQuota'), "localDeliveryOnly" => array( "_off", 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'), "dropOwnMails" => array( "_off", 'acctDelFilter','acctGetFilters','acctSetFilters','acctSetFilters'), "mailFolder" => array( 'folderList','folderDel','folderAdd'), "mailLimit" => array( 'acctGetMailLimit', 'acctSetMailLimit'), //Just for speedup "folderListWithMembers" => array( 'acctGetComprehensiveUser'), "folderACLs" => array( 'folderGetMembers', 'folderSetMembers'), "comprehensiveUser" => array( 'acctGetComprehensiveUser') ); // Check if all required methods can be called! foreach($featureReq as $name => $requires){ $active = TRUE; foreach($requires as $methodName){ $active &= $this->groupwareDao->gwFeatureAvailable($methodName); } $this->enabledFeatures[$name] = $active; } // Load mail locations. if ($this->isFeatureEnabled("mailLocations")){ $this->mailLocations = $this->groupwareDao->get('mailLocations', array()); } // If this is a new user, then do not try to check the account status, // the account cannot exists. if($this->dn == "new"){ $this->initially_was_account = $this->is_account = FALSE; $this->accountInitialized = TRUE; }else{ // Get rpc handle to fetch account info and feature availability. $status = $this->rpcExec('gwAcctExists', $this->uid); if($status !== NULL){ $this->initially_was_account = $this->is_account = $status; if($this->is_account){ $response = $this->groupwareDao->getComprehensiverUser($this->uid); $this->saved_attributes = $response; $this->mapComprehensiveUserData($response); } $this->accountInitialized = TRUE; } } // Set vacation start/stop if not set alreasy $this->vacationStart = time(); $this->vacationStop = time() + (14 * 60*60*24); // Prepare vacation start/stop time to be initially valid. $this->vacationStart= date('d.m.Y', $this->vacationStart); $this->vacationStop= date('d.m.Y', $this->vacationStop); } /*! \brief Generates the HTML user interface for the groupware plugin * and take of several ui actions like adding or removing * forward addresses, filters and the account itself. */ function execute() { // Register plugin execution $display = plugin::execute(); // Log plugin execution. if($this->is_account && !$this->view_logged){ $this->view_logged = TRUE; new log("view","users/".get_class($this),$this->dn); } // Check if we were able to initialize the account already. if(!$this->accountInitialized){ $this->init(); if(!$this->accountInitialized){ $smarty = get_smarty(); $smarty->assign("initFailed", !$this->accountInitialized); return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); } } // Check if we were able to initialize the account already. if($this->rpcError){ $smarty = get_smarty(); $smarty->assign("initFailed", !$this->accountInitialized); $smarty->assign("rpcError", $this->rpcError); return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); } /**************** Filter editor ****************/ if(isset($_POST['filterManager_cancel'])) $this->filterManager = NULL; if(isset($_POST['filterManager_ok'])){ $this->filterManager->save_object(); $msgs = $this->filterManager->check(); if(count($msgs)){ msg_dialog::displayChecks($msgs); }else{ $this->filterRules = $this->filterManager->save(); $this->filterManager = NULL; } } if(isset($_POST['configureFilter'])){ $this->filterManager = new FilterManager($this->config, $this,$this->filterRules); $this->filterManager->acl_base = $this->acl_base; $this->filterManager->acl_category = $this->acl_category; } $this->dialog = FALSE; if($this->filterManager instanceOf FilterManager){ $this->filterManager->save_object(); $this->dialog = TRUE; return($this->filterManager->execute()); } /**************** Folder editor ****************/ if(isset($_POST['FolderWidget_cancel'])) $this->FolderWidget = NULL; if(isset($_POST['FolderWidget_ok'])){ $this->FolderWidget->save_object(); $msgs = $this->FolderWidget->check(); if(count($msgs)){ msg_dialog::displayChecks($msgs); }else{ if(!empty($this->mailFolderChanges)){ $this->mailFolderChanges = array_merge($this->mailFolderChanges, $this->FolderWidget->save()); } else{ $this->mailFolderChanges = $this->FolderWidget->save(); } $this->folderSave($this->uid); $this->FolderWidget = NULL; } } // Act on requests to edit mailFolder entries. if(isset($_POST['configureFolder'])){ // Load mail folder entries on demand, this will increase the account // instantiation a lot. if($this->mailFolder === NULL){ $this->mailFolder = array(); if($this->initially_was_account){ $this->mailFolder = $this->groupwareDao->getListOfMailFolders(); } } $folders = $this->mailFolder; if(!isset($folders[$this->folderPrefix])){ $folders[$this->folderPrefix] = array('name' => $this->uid,'status' => 'added','acls' => array()); } $this->FolderWidget = new FolderWidget($this->config,$folders, $this->folderPrefix); $this->FolderWidget->setPermissions(GroupwareDefinitions::getPermissions()); $this->FolderWidget->acl_base = $this->acl_base; $this->FolderWidget->acl_category = $this->acl_category; } $this->dialog = FALSE; if($this->FolderWidget instanceOf FolderWidget){ $this->FolderWidget->save_object(); $this->dialog = TRUE; return($this->FolderWidget->execute()); } /**************** Account status ****************/ if(isset($_POST['modify_state'])){ if($this->is_account && $this->acl_is_removeable()){ $this->is_account= FALSE; }elseif(!$this->is_account && $this->acl_is_createable()){ $this->is_account= TRUE; } } if(!$this->multiple_support_active){ if (!$this->is_account && $this->parent === NULL){ $display= "\"\" ". msgPool::noValidExtension(_("Mail")).""; $display.= back_to_main(); return ($display); } if ($this->parent !== NULL){ if ($this->is_account){ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Groupware")), msgPool::featuresEnabled(_("Groupware"))); } else { $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Groupware")), msgPool::featuresDisabled(_("Groupware"))); return ($display); } } } /**************** Forward addresses ****************/ // Display dialog to select a local fowarder if (isset($_POST['addLocalForwardingAddress'])){ $this->mailAddressSelectDialog= new mailAddressSelect($this->config, get_userinfo()); $this->dialog= TRUE; } // Close dialogs, action was canceled if (isset($_POST['mailAddressSelect_cancel'])){ $this->mailAddressSelectDialog= FALSE; $this->dialog= FALSE; } // Append selected forwarding addresses now. if (isset($_POST['mailAddressSelect_save']) && $this->mailAddressSelectDialog instanceOf mailAddressSelect){ if($this->acl_is_writeable("forwardingAddresses")){ $list = $this->mailAddressSelectDialog->save(); foreach ($list as $entry){ $val = $entry['mail'][0]; if (!in_array_strict($val, $this->alternateAddresses) && $val != $this->mailAddress){ $this->addForwarder($val); $this->is_modified= TRUE; } } $this->mailAddressSelectDialog= FALSE; $this->dialog= FALSE; } else { msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG); } } // Display the address selection dialog. if($this->mailAddressSelectDialog instanceOf mailAddressSelect){ $used = array(); $used['mail'] = array_values($this->alternateAddresses); $used['mail'] = array_merge($used['mail'], array_values($this->forwardingAddresses)); $used['mail'][] = $this->mailAddress; // Build up blocklist session::set('filterBlacklist', $used); return($this->mailAddressSelectDialog->execute()); } // Add manually inserted forwarding address. if (isset($_POST['addForwardingAddress'])){ if ($_POST['forwardingAddressInput'] != ""){ $address= get_post('forwardingAddressInput'); $valid= FALSE; if (!tests::is_email($address)){ if (!tests::is_email($address, TRUE)){ if ($this->is_template){ $valid= TRUE; } else { msg_dialog::display(_("Error"), msgPool::invalid(_("Mail address"), "","","your-address@your-domain.com"),ERROR_DIALOG); } } } elseif ($address == $this->mailAddress || in_array_strict($address, $this->alternateAddresses)) { msg_dialog::display(_("Error"),_("Cannot add primary address to the list of forwarders!") , ERROR_DIALOG); } else { $valid= TRUE; } if ($valid){ if($this->acl_is_writeable("forwardingAddresses")){ $this->addForwarder ($address); $this->is_modified= TRUE; } } } } if (isset($_POST['deleteForwardingAddress'])){ $this->delForwarder ($_POST['forwardingAddressList']); } /**************** Alternate addresses ****************/ // Add manually inserted alternate mail address. if (isset($_POST['addAlternateAddress'])){ $valid= FALSE; if (!tests::is_email($_POST['alternateAddressInput'])){ if ($this->is_template){ if (!(tests::is_email($_POST['alternateAddressInput'], TRUE))){ msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"), "","","your-domain@your-domain.com"),ERROR_DIALOG); } else { $valid= TRUE; } } else { msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"), "","","your-domain@your-domain.com"),ERROR_DIALOG); } } else { $valid= TRUE; } if ($valid && ($user= $this->addAlternate (get_post('alternateAddressInput'))) != ""){ $ui= get_userinfo(); $addon= ""; if ($user[0] == "!") { $addon= sprintf(_("Address is already in use by group '%s'."), mb_substr($user, 1)); } else { $addon= sprintf(_("Address is already in use by user '%s'."), $user); } msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))."

". "$addon", ERROR_DIALOG); } } // Remove alternate mail address. if (isset($_POST['deleteAlternateAddress']) && isset($_POST['alternateAddressList'])){ $this->delAlternate ($_POST['alternateAddressList']); } /**************** SMARTY- Assign smarty variables ****************/ $smarty = get_smarty(); foreach($this->attributes as $attr){ print $smarty->assign($attr, $this->$attr); } $plInfo = $this->plInfo(); foreach($plInfo['plProvidedAcls'] as $acl => $name){ $smarty->assign($acl."ACL", $this->getacl($acl)); } foreach($this->enabledFeatures as $feature => $state){ $smarty->assign($feature."_isActive", $state); } $smarty->assign("mailLocations", $this->mailLocations); if (count($this->vacationTemplates)){ $smarty->assign("displayTemplateSelector", "TRUE"); $smarty->assign("vacationTemplate", set_post($this->vacationTemplate)); $smarty->assign("vacationTemplates", set_post($this->vacationTemplates)); $smarty->assign("template", set_post(get_post('vacation_template'))); } else { $smarty->assign("displayTemplateSelector", "FALSE"); } $smarty->assign("uid", $this->uid); $smarty->assign("initFailed", !$this->accountInitialized); $smarty->assign("rpcError", $this->rpcError); $smarty->assign("rpcErrorMessage", $this->rpcErrorMessage); return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); } /*! \brief This method handles potential _POST and _GET values. * It captures modifcations from the ui, like changing * the mailAddress. * This method respects the attribute permissions. */ function save_object() { if(isset($_POST['groupwarePluginPosted'])){ // We ran into a communication error with the backend. // Try a simple communication operation with the backend // again and let us see if it works. if(isset($_POST['retry'])){ $this->rpcExec('gwGetCapabilities'); } // Get posted mail address modifications if(isset($_POST['mailAddress']) && $this->acl_is_writeable('mailAddress') && $this->isFeatureEnabled('primaryMail')){ $this->mailAddress = get_post('mailAddress'); } // Get ui modifications and store them in the class. $testAttrs = array("mailLocation","quotaUsage","quotaSize", "alternateAddresses","forwardingAddresses","vacationMessage"); foreach($testAttrs as $attr){ if(isset($_POST[$attr]) && $this->acl_is_writeable($attr) && $this->isFeatureEnabled($attr)){ $this->$attr = get_post($attr); } } // Detect checkbox states $checkAttrs = array( "mailBoxWarnLimit" => "mailBoxWarnLimit", "mailBoxSendSizelimit" => "mailBoxSendSizelimit", "mailBoxHardSizelimit" => "mailBoxHardSizelimit", "mailBoxAutomaticRemoval" => "mailBoxAutomaticRemoval", "mailLimitReceive" => "mailLimit", "mailLimitSend" => "mailLimit"); foreach($checkAttrs as $boxname => $feature){ if($this->acl_is_writeable($boxname) && $this->isFeatureEnabled($feature)){ $v = $boxname."Value"; $e = $boxname."Enabled"; $this->$e = isset($_POST[$e]); if($this->$e){ $this->$v = get_post($v); } } } // Check for a changed vacation status if($this->acl_is_writeable('vacationMessage') && $this->isFeatureEnabled('vacationMessage')){ $this->vacationEnabled = isset($_POST['vacationEnabled']); } // Get posted flag changes $flagAttrs = array("localDeliveryOnly","dropOwnMails"); foreach($flagAttrs as $attr){ if($this->acl_is_writeable($attr) && $this->isFeatureEnabled($attr)){ $this->$attr = isset($_POST[$attr]); } } } } /*! \brief Parse vacation templates and build up an array * containing 'filename' => 'description'. * Used to fill vacation dropdown box. * @return Array All useable vacation templates. */ function get_vacation_templates_usedSomewhere() { $vct = array(); if ($this->config->get_cfg_value("core","vacationTemplateDirectory") != ""){ $dir= $this->config->get_cfg_value("core","vacationTemplateDirectory"); if (is_dir($dir) && is_readable($dir)){ $dh = opendir($dir); while($file = readdir($dh)){ $description= ""; if (is_file($dir."/".$file)){ $fh = fopen($dir."/".$file, "r"); $line= fgets($fh, 256); if (!preg_match('/^DESC:/', $line)){ msg_dialog::display(_("Configuration error"), sprintf(_("No DESC tag in vacation template '%s'!"), $file), ERROR_DIALOG); }else{ $description= trim(preg_replace('/^DESC:\s*/', '', $line)); } fclose ($fh); } if ($description != ""){ $vct["$dir/$file"]= $description; } } closedir($dh); } } return($vct); } /*! \brief Adds the given mail address to the list of mail forwarders */ function addForwarder($address) { if(empty($address)) return; if($this->acl_is_writeable("forwardingAddresses")){ //Check if the address is a valid address on the Groupwareserver $isMailAvailabel = $this->rpcExec("gwMailAddressExists", $address); if(empty($isMailAvailabel)){ msg_dialog::display(_("Permission error"), _("This email address is not available as forwarding recipient in your groupware."), ERROR_DIALOG); } else{ $this->forwardingAddresses[]= $address; $this->forwardingAddresses= array_unique ($this->forwardingAddresses); sort ($this->forwardingAddresses); reset ($this->forwardingAddresses); $this->is_modified= TRUE; } }else{ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG); } } /*! \brief Removes the given mail address from the list of mail forwarders */ function delForwarder($addresses) { if($this->acl_is_writeable("forwardingAddresses")){ $this->forwardingAddresses= array_remove_entries ($addresses, $this->forwardingAddresses); $this->is_modified= TRUE; }else{ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG); } } /*! \brief Add given mail address to the list of alternate adresses , * check if this mal address is used, skip adding in this case */ function addAlternate($address) { if(empty($address)) return; if($this->acl_is_writeable("alternateAddresses")){ $ldap= $this->config->get_ldap_link(); $address= strtolower($address); /* Is this address already assigned in LDAP? */ $ldap->cd ($this->config->current['BASE']); $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)". "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid", "cn")); if ($ldap->count() > 0){ $attrs= $ldap->fetch (); if (!isset($attrs["uid"])) { return ("!".$attrs["cn"][0]); } return ($attrs["uid"][0]); } if (!in_array_strict($address, $this->alternateAddresses)){ $this->alternateAddresses[]= $address; $this->is_modified= TRUE; } sort ($this->alternateAddresses); reset ($this->alternateAddresses); return (""); }else{ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG); } } /*! \brief Removes the given mail address from the alternate addresses list */ function delAlternate($addresses) { if($this->acl_is_writeable("alternateAddresses")){ $this->alternateAddresses= array_remove_entries ($addresses,$this->alternateAddresses); $this->is_modified= TRUE; }else{ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG); } } /*! \brief Prepare importet vacation string. \ * Replace placeholder like %givenName a.s.o. * @param string Vacation string * @return string Completed vacation string */ private function prepare_vacation_template_usedSomewhere($contents) { /* Replace attributes */ $attrs = array(); $obj = NULL; if(isset($this->parent->by_object['user'])){ $attrs = $this->parent->by_object['user']->attributes; $obj = $this->parent->by_object['user']; }else{ $obj = new user($this->config,$this->dn); $attrs = $obj->attributes; } if($obj){ /* Replace vacation start and end time */ if($this->enabledFeatures['vacationMessage']){ if(preg_match("/%start/",$contents)){ $contents = preg_replace("/%start/",$this->vacationStart,$contents); } if(preg_match("/%end/",$contents)){ $contents = preg_replace("/%end/",$this->vacationStop,$contents); } }else{ if(preg_match("/%start/",$contents)){ $contents = preg_replace("/%start/", _("unknown"),$contents); } if(preg_match("/%end/",$contents)){ $contents = preg_replace("/%end/", _("unknown"), $contents); } } foreach ($attrs as $val){ // We can only replace strings here if(!is_string($obj->$val)) continue; if(preg_match("/dateOfBirth/",$val)){ if($obj->use_dob){ $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents); } }else { $contents= preg_replace("/%$val/", $obj->$val, $contents); } } } $contents = ltrim(preg_replace("/^DESC:.*$/m","",$contents),"\n "); return($contents); } /*! \brief Remove the account form the groupware server completely. */ function remove_from_parent() { // Get rpc handle to remove the account if($this->initially_was_account){ if($this->rpcExec('gwAcctDel', $this->uid) === NULL){ msg_dialog::display(_("Error"), _("Groupware account removal failed!"), ERROR_DIALOG); } } } /* \brief Persists the values of this plugin to the groupware server. * Save method is called on "apply" and "ok" in the Gosa Frontend. * All other actions will update values in the form or * cancel and therefore discard the changes so far. */ function save() { // Get rpc handle to create or update the account if(!$this->initially_was_account){ $res = $this->rpcExec('gwAcctAdd', $this->uid, $this->mailAddress); if($res === NULL){ $message = _("Groupware account creation failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); return; } } // Save the primary Email Address. if($this->isFeatureEnabled("primaryMail")&& $this->hasFeaturebeenChanged("primaryMail")){ $res = $this->groupwareDao->save("primaryMail", $this->uid, $this->mailAddress); if($res === NULL){ $message = _("Setting account mail address failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } // Save alternateAddresses if($this->isFeatureEnabled("alternateAddresses")&& $this->hasFeaturebeenChanged("alternateAddresses")){ if(isset($this->alternateAddresses) && is_array($this->alternateAddresses)){ if(!empty($this->alternateAddresses)){ $res = $this->groupwareDao->save("alternateAddresses", $this->uid, array($this->alternateAddresses)); } else{ $res = $this->groupwareDao->save("alternateAddresses", $this->uid, array(array())); } if($res === NULL){ $message = _("Saving alternate addresses failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } } // Save forwardingAddresses if($this->isFeatureEnabled("forwardingAddresses") && $this->hasFeaturebeenChanged("forwardingAddresses")){ // Transform simple address array into, $addresses[address] = ForwardFlag; $addresses = array(); if(!empty($this->forwardingAddresses)){ foreach($this->forwardingAddresses as $address) $addresses[$address] = TRUE; $res = $this->groupwareDao->save("forwardingAddresses", $this->uid, array($addresses)); } else{ $res = $this->groupwareDao->save("forwardingAddresses", $this->uid, array(array())); } if($res === NULL){ $message = _("Saving forward addresses failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } //Save quota - it consists of four values... if( ($this->isFeatureEnabled("mailBoxWarnLimit") || $this->isFeatureEnabled("mailBoxSendSizelimit") || $this->isFeatureEnabled("quotaSize") || $this->isFeatureEnabled("mailBoxAutomaticRemoval")) && ($this->hasFeaturebeenChanged("mailBoxWarnLimit") || $this->hasFeaturebeenChanged("mailBoxSendSizelimit") || $this->hasFeaturebeenChanged("quotaSize") || $this->hasFeaturebeenChanged("mailBoxAutomaticRemoval") )){ if(!$this->mailBoxWarnLimitEnabled){ $this->mailBoxWarnLimitValue = null; } if(!$this->mailBoxSendSizelimitEnabled){ $this->mailBoxSendSizelimitValue = null; } $quota = array( "warn_limit" => $this->mailBoxWarnLimitValue, "send_limit" => $this->mailBoxSendSizelimitValue, "hard_limit" => $this->quotaSize); //hold cannot be saved (in Exchange) right now - should be excluded for now. //"hold" => $this->mailBoxAutomaticRemovalValue); $res = $this->groupwareDao->save("quotaSize", $this->uid, $quota); if($res === NULL){ $message = _("Saving quota failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } // TODO: Check the following paragraph // Save account folders if($this->mailFolder !== NULL && $this->isFeatureEnabled("mailFolder") && $this->hasFeaturebeenChanged("mailFolder")){ //$res = $this->saveFoldersAndAcls($this->uid, $this->mailFolder); if($res === NULL){ $message = _("Saving mail folder failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } if($this->isFeatureEnabled("mailLocations") && $this->hasFeaturebeenChanged("mailLocation")){ $res = $this->groupwareDao->save("mailLocation", $this->uid, $this->mailLocation); if($res === NULL){ $message = _("Saving mail location failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } //checks for feature "mailLimit" if($this->isFeatureEnabled("mailLimit") && $this->hasFeaturebeenChanged("mailLimit")){ if(!$this->mailLimitReceiveEnabled){ $this->mailLimitReceiveValue = 0; } if(!$this->mailLimitSendEnabled){ $this->mailLimitSendValue = 0; } $res = $this->groupwareDao->save("mailLimit", $this->uid, array( $this->mailLimitSendValue, $this->mailLimitReceiveValue)); if($res === NULL){ $message = _("Saving mail limitations failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } if($this->isFeatureEnabled("vacationMessage")&& $this->hasFeaturebeenChanged("vacationMessage")){ if($this->vacationEnabled){ //setting an message means that the OOOReply is switched off. $res = $this->groupwareDao->save("vacationMessage", $this->uid, $this->vacationMessage); }else{ //setting no message means that the OOOReply is switched off. $res = $this->groupwareDao->save("vacationMessage", $this->uid, null); } if($res === NULL){ $message = _("Saving vacation message failed!"); msg_dialog::display(_("Error"),$message."
".sprintf(_("Error was: '%s'."),$this->rpcErrorMessage),ERROR_DIALOG); } } //Todo: Remove this $this->folderSave($this->uid); } //checks for feature "quotaUsage" //not to be saved # //checks for feature "mailFilter" # if($this->isFeatureEnabled("mailFilter") && $this->hasFeaturebeenChanged("mailFilter")){} # # //checks for feature "mailBoxAutomaticRemoval" # if($this->isFeatureEnabled("mailBoxAutomaticRemoval") && $this->hasFeaturebeenChanged("mailBoxAutomaticRemoval")){} # # //checks for feature "localDeliveryOnly" # if($this->isFeatureEnabled("localDeliveryOnly") && $this->hasFeaturebeenChanged("localDeliveryOnly")){} # # //checks for feature "dropOwnMails" # if($this->isFeatureEnabled("dropOwnMails") && $this->hasFeaturebeenChanged("dropOwnMails")){} /*! \brief TODO remove this function later */ function folderSave($id){ if($this->isFeatureEnabled("mailFolder")&& $this->hasFeaturebeenChanged("mailFolder")){ //is sorting necessary? //Find folders to add if(empty($this->mailFolderChanges)){ return; } //Remove the root folder - the widget adds it as new unset($this->mailFolderChanges["user/".$this->uid]); foreach($this->mailFolderChanges as $folder => $memberlist){ if($this->mailFolderChanges[$folder]["status"] == "added"){ $this->groupwareDao->save("mailFolder", $folder); } if($this->mailFolderChanges[$folder]["status"] == "removed"){ $this->groupwareDao->del("mailFolder", $folder); } $memberListToBeSaved = array(); if($this->isFeatureEnabled("folderACLs")){ //checking if ACL has been changed. if($this->mailFolderChanges[$folder]["status"] == "added"){ if(isset($memberlist["acls"])){ //set Default ACLs if not yet set by User $defAcls = GroupwareDefinitions::getDefaultFolderACLs(); $memberListToBeSaved = $defAcls; //append all mebers set in Gosa widget. foreach($memberlist["acls"] as $member){ $memberListToBeSaved[$member["name"]] = $member["acl"]; } } } else{ //Todo: remove debugs /* echo "--- Hello1"; print_a($memberlist["acls"]); echo "--- Hello2"; print_a($this->mailFolderChanges[$folder]["acls"]); */ if(array_differs($memberlist["acls"], $this->mailFolder[$folder]["acls"])){ //append all mebers set in Gosa widget. echo "ACLs have changed."; foreach($memberlist["acls"] as $member){ $memberListToBeSaved[$member["name"]] = $member["acl"]; } } } if(!empty($memberListToBeSaved)){ //Todo: remove debugs /* echo "List To save:
";
						print_r($memberListToBeSaved);
						echo "

"; */ $this->groupwareDao->save("folderACLs", $folder, array($memberListToBeSaved)); } } } } //reset the changes.. we have persisted them. $this->mailFolderChanges = null; } /*! \brief Check given values */ function check() { //checke features only if they are enabled. $messages = plugin::check(); // For newly created users! // We can input every 'uid' we want for new users, so we've to check if uids weren't used yet. if(!$this->initially_was_account){ $exists = $this->rpcExec('gwAcctExists', $this->uid); if($this->rpcError){ $messages[] = sprintf(_("Failed to validate groupware account."), $this->uid); }elseif($exists){ $messages[] = sprintf(_("Account id, already used '%s'!"), $this->uid); } } // Check for valid mailAddresses if ($this->isFeatureEnabled("primaryMail")){ if(!tests::is_email ($this->mailAddress)){ $messages[] = msgPool::invalid(_("Mail address"),$this->mailAddress , "", "user@exdom.intranet.gonicus.de knibbel"); } // Ensure that the mailAddress isn't used yet. if(!$this->initially_was_account || $this->mailAddress != $this->saved_attributes['primaryMail']){ $exists = $this->rpcExec("gwMailAddressExists", $this->mailAddress); if($this->rpcError){ $messages[] = sprintf(_("Failed to validate mail address '%s'."), $this->mailAddress); }elseif($exists){ $messages[] = msgPool::duplicated(_("Mail address")); } } } //checks for feature "forwardingAddresses" if ($this->isFeatureEnabled("forwardingAddresses")){ if(isset($this->forwardingAddresses) && is_array($this->forwardingAddresses)){ foreach($this->forwardingAddresses as $fAddress){ if(!tests::is_email ($fAddress)){ $messages[] = msgPool::invalid(_("Forwarding address"),$fAddress, "", "user@exdom.intranet.gonicus.de"); } //Check if the address is a valid address on the Groupwareserver $isMailAvailabel = $this->rpcExec("gwMailAddressExists", $fAddress); if(empty($isMailAvailabel)){ $messages[] = _("This email address is not available as forwarding recipient in your groupware."); } if($fAddress == $this->mailAddress){ $messages[] = _("The primary address cannot be used as forwarding address!"); } } } } //checks for feature "mailLimit" - integer if ($this->isFeatureEnabled("mailLimit")){ if (!is_numeric($this->mailLimitReceiveValue)){ $messages[] = msgPool::invalid(_("Value for mailbox size receive limit"),$this->mailLimitReceiveValue , "", "1024 = 1MB"); } if (!is_numeric($this->mailLimitSendValue)){ $messages[] = msgPool::invalid(_("Value for mailbox size send limit"),$this->mailLimitSendValue , "", "1024 = 1MB"); } } //checks for feature "mailBoxWarnLimit" if ($this->isFeatureEnabled("quotaSize")){ //Todo: wrong test if (!is_numeric($this->quotaSize)){ $messages[] = msgPool::invalid(_("Value for Quota size"),$this->quotaSize , "", "1024 = 1GB"); } } //checks for feature "mailBoxSendSizelimit" if ($this->isFeatureEnabled("mailBoxSendSizelimit")){ //Todo: wrong test if (!is_numeric($this->mailBoxSendSizelimitValue)){ $messages[] = msgPool::invalid(_("Value refuse incoming mails limit"),$this->mailBoxSendSizelimitValue , "", "1024 = 1GB"); } } //checks for feature "mailBoxHardSizelimit" if ($this->isFeatureEnabled("mailBoxWarnLimit")){ //Todo: wrong test if (!is_numeric($this->mailBoxWarnLimitValue)){ $messages[] = msgPool::invalid(_("Value warn about full mailbox"),$this->mailBoxWarnLimitValue , "", "1024 = 1GB"); } } # //checks for feature "vacationMessage" # if ($this->isFeatureEnabled("vacationMessage")){} # # //checks for feature "mailBoxAutomaticRemoval" # if ($this->isFeatureEnabled("mailBoxAutomaticRemoval")){} # # //checks for feature "localDeliveryOnly" # if ($this->isFeatureEnabled("localDeliveryOnly")){} # # //checks for feature "dropOwnMails" # if ($this->isFeatureEnabled("dropOwnMails")){} # # //checks for feature "mailFolder" # if ($this->isFeatureEnabled("mailFolder")){} # # //checks for feature "quotaUsage" # if ($this->isFeatureEnabled("quotaUsage")){} # # //checks for feature "mailLocations" # if ($this->isFeatureEnabled("mailLocations")){} # # //checks for feature "mailFilter" # if ($this->isFeatureEnabled("mailFilter")){} # # //checks for feature "alternateAddresses" # if ($this->isFeatureEnabled("alternateAddresses")){} return($messages); } /*! \brief ACL settings */ static function plInfo() { return (array( "plShortName" => _("Groupware"), "plDescription" => _("Groupware settings"), "plSelfModify" => TRUE, "plDepends" => array("user"), // This plugin depends on "plPriority" => 4, // Position in tabs "plSection" => array("personal" => _("My account")), "plCategory" => array("users"), "plOptions" => array(), "plProvidedAcls" => array( "mailAddress" => _("Mail address"), "mailLocation" => _("Mail location"), "mailFolder" => _("Mail folder"), "quotaUsage" => _("Quota usage"), "mailFilter" => _("Mail filter"), "mailFilter" => _("Mail filter"), "quotaSize" => _("Quota size"), "alternateAddresses" => _("Alternate mail addresses"), "forwardingAddresses" => _("Forwarding mail addresses"), "vacationEnabled" => _("Vaction switch"), "vacationMessage" => _("Vacation message"), "mailBoxWarnLimit" => _("Warn sizelimit"), "mailBoxSendSizelimit" => _("Send sizelimit"), "mailBoxHardSizelimit" => _("Hard sizelimit"), "mailBoxAutomaticRemoval" => _("Automatic mail removal"), "localDeliveryOnly" => _("Local delivery only"), "dropOwnMails" => _("Drop own mails"), "mailLimitSend" => _("mail Limit send"), "mailLimitReceive" => _("mail Limit receive") ) )); } /*! \brief Maps the resultset fetched from the Dao to the class variables * of the plugin. */ function mapComprehensiveUserData($callBackMap) { $map = array( "mailLocations" => "mailLocations", "mailFolder" => "mailFolder", "mailAddress" => "primaryMail", "mailLocation" => "mailLocation", "quotaUsage" => "quotaUsage", "quotaSize" => "mailBoxHardSizelimitValue", "alternateAddresses" => "alternateAddresses", "forwardingAddresses" => "forwardingAddresses", "vacationEnabled" => "vacationEnabled", "vacationMessage" => "vacationMessage", "mailBoxWarnLimitEnabled" => "mailBoxWarnLimitEnabled", "mailBoxWarnLimitValue" => "mailBoxWarnLimitValue", "mailBoxSendSizelimitEnabled" => "mailBoxSendSizelimitEnabled", "mailBoxSendSizelimitValue" => "mailBoxSendSizelimitValue", "mailBoxHardSizelimitEnabled" => "mailBoxHardSizelimitEnabled", "mailBoxHardSizelimitValue" => "mailBoxHardSizelimitValue", "mailBoxAutomaticRemovalEnabled" => "mailBoxAutomaticRemovalEnabled", "mailBoxAutomaticRemovalValue" => "mailBoxAutomaticRemovalValue", "localDeliveryOnly" => "localDeliveryOnly", "dropOwnMails" => "dropOwnMails", "mailLimitReceiveValue" => "mailLimitReceiveValue", "mailLimitSendValue" => "mailLimitSendValue", "mailLimitReceiveEnabled" => "mailLimitReceiveEnabled", "mailLimitSendEnabled" => "mailLimitSendEnabled" ); // Map values from source array to class members foreach($map as $target => $source){ if(isset($callBackMap[$source])){ $this->$target = $callBackMap[$source]; } } } /*! \brief This is a feature with many datasets inside which should be function saveFoldersAndAcls($id, $mailFolder) { // In the tests with the exchange server groupware setting acls is very // slow. So this function has got o be checked for modifications. $res = TRUE; foreach($mailFolder as $key => $val) { if(!empty($val["status"])){ switch($val["status"]){ case "add": $res = $this->groupwareDao->save("mailFolder", $id, $key); break; case "del": $res = $this->groupwareDao->delete("mailFolder", $id, $key); break; } } if($res === NULL) return($res); } return($res); } */ } ?> gosa-plugin-groupware-2.7.4/addons/0000755000175000017500000000000011752422556016237 5ustar cajuscajusgosa-plugin-groupware-2.7.4/locale/0000755000175000017500000000000011752422556016226 5ustar cajuscajusgosa-plugin-groupware-2.7.4/admin/0000755000175000017500000000000011752422556016057 5ustar cajuscajusgosa-plugin-groupware-2.7.4/admin/ogroups/0000755000175000017500000000000011752422556017555 5ustar cajuscajusgosa-plugin-groupware-2.7.4/admin/ogroups/GroupwareDistributionList/0000755000175000017500000000000011752422556024764 5ustar cajuscajus././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootgosa-plugin-groupware-2.7.4/admin/ogroups/GroupwareDistributionList/class_GroupwareDistributionList.incgosa-plugin-groupware-2.7.4/admin/ogroups/GroupwareDistributionList/class_GroupwareDistributionList.0000644000175000017500000005435511613742614033371 0ustar cajuscajuscn = ""; if(isset($this->attrs['cn'])){ $this->cn = $this->attrs['cn'][0]; } $this->orig_cn = $this->cn; // Initialize the distribution list using the gosa-ng backend $this->init(); } /*! \brief Check whether a feature is enabled or not. * @param The feature name to check for * @return TRUE on success else FALSE */ function featureEnabled($name) { return(isset($this->featuresEnabled[$name]) && $this->featuresEnabled[$name]); } /*! \brief Try to initialize the plugin using a json-rpc connection * to the gosa-ng server. */ function init() { // Detect supported capabilities $rpc = $this->config->getRpcHandle(); $capabilities = $rpc->gwGetCapabilities(); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load supported capabilities from server! Error was: '%s'."), $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } // Detect features we can use $map['alternateAddresses'] = array('distGetAlternateMailAddresses','distSetAlternateMailAddresses'); $map['mailSizeLimit'] = array('distGetMailLimit','distGetMailLimit'); foreach($map as $name => $required){ $this->featuresEnabled[$name] = TRUE; foreach($required as $func){ $this->featuresEnabled[$name] &= isset($capabilities[$func]) && $capabilities[$func]; } } // If we're creating a new ogroup, then we've definately no extension, yet. $this->rpcError = FALSE; if($this->cn == "" || $this->dn == "new"){ $is_account = FALSE; }else{ // Check whether a mathing distribution-list exists or not! $is_account = $rpc->gwDistExists($this->orig_cn); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to check existence for distribution list '%s'! Error was: '%s'."), $this->orig_cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } } // We've detected a valid distribution list, now load all // configured members, so we're able to update the memberlist // on save(); $memberList = array(); $primaryMailAddress = ""; $mailSizeLimit = NULL; $alternateAddresses = array(); if($is_account){ // Load list of members $memberList = $rpc->gwDistGetMembers($this->orig_cn); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load members for distribution list '%s'! Error was: '%s'."), $this->orig_cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } // Now get the primary mail address $primaryMailAddress = $rpc->gwDistGetPrimaryMailAddress($this->orig_cn); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load the primary mail address for distribution list '%s'! Error was: '%s'."), $this->orig_cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } // Load alternate mail address if($this->featureEnabled('alternateAddresses')){ $alternateAddresses = $rpc->gwDistGetAlternateMailAddresses($this->orig_cn); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load alternate mail addresses for distribution list '%s'! Error was: '%s'."), $this->orig_cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } } // Load mail size limitation settings if($this->featureEnabled('mailSizeLimit')){ $mailSizeLimit = $rpc->gwDistGetMailLimit($this->orig_cn); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load mail size limit for distribution list '%s'! Error was: '%s'."), $this->orig_cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } $mailSizeLimit = $mailSizeLimit['receive']; } } // Store values as current and initial values (saved_attributes) // to be able to keep track och changes. $this->is_account = $this->initially_was_account = $is_account; $this->saved_attributes = array(); $this->memberList = $this->saved_attributes['memberList'] = $memberList; $this->primaryMailAddress = $this->saved_attributes['primaryMailAddress'] = $primaryMailAddress; $this->alternateAddresses = $this->saved_attributes['alternateAddresses'] = $alternateAddresses; $this->mailSizeLimit = $this->saved_attributes['mailSizeLimit'] = $mailSizeLimit; $this->capabilities = $capabilities; $this->initialized = TRUE; } /*! \brief Gets the uids for the ogroup members. */ function getOgroupMemberList() { $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); $members = array(); foreach($this->parent->by_object['ogroup']->memberList as $dn => $data){ if($data['type'] == 'U'){ $ldap->cat($dn, array('uid')); if($ldap->count()){ $attrs = $ldap->fetch(); if(isset($attrs['uid'][0])) $members[] = $attrs['uid'][0]; } } } return($members); } function execute() { plugin::execute(); // Initialization failed - Display a stripped template which allows // to retry initialization if(!$this->initialized){ $smarty = get_smarty(); $smarty->assign('rpcError' , $this->rpcError); $smarty->assign('rpcErrorMessage' , $this->rpcErrorMessage); return($smarty->fetch(get_template_path('GroupwareDistributionList/initFailed.tpl', TRUE))); } // Log account access if($this->is_account && !$this->view_logged){ $this->view_logged = TRUE; new log("view","ogroups/".get_class($this),$this->dn); } // Allow to add or remove the distribution list extension if(isset($_POST['modify_state'])){ if($this->is_account && $this->acl_is_removeable()){ $this->is_account= FALSE; }elseif(!$this->is_account && $this->acl_is_createable()){ $this->is_account= TRUE; } } // Show account status-changer if ($this->parent !== NULL){ if ($this->is_account){ $display= $this->show_disable_header(_("Remove distribution list"), msgPool::featuresEnabled(_("Distribution list"))); } else { $display= $this->show_enable_header(_("Create distribution list"), msgPool::featuresDisabled(_("Distribution list"))); return ($display); } } /**************** Alternate addresses ****************/ // Add manually inserted alternate mail address. if (isset($_POST['addAlternateAddress'])){ $valid= FALSE; if (!tests::is_email($_POST['alternateAddressInput'])){ msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"), "","","your-domain@your-domain.com"),ERROR_DIALOG); } else { $valid= TRUE; } if ($valid && ($user= $this->addAlternate (get_post('alternateAddressInput'))) != ""){ $ui= get_userinfo(); $addon= ""; if ($user[0] == "!") { $addon= sprintf(_("Address is already in use by group '%s'."), mb_substr($user, 1)); } else { $addon= sprintf(_("Address is already in use by user '%s'."), $user); } msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))."

". "$addon", ERROR_DIALOG); } } // Remove alternate mail address. if (isset($_POST['deleteAlternateAddress']) && isset($_POST['alternateAddressList'])){ $this->delAlternate ($_POST['alternateAddressList']); } /**************** Generate HTML output ****************/ $smarty = get_smarty(); $smarty->assign('rpcError' , $this->rpcError); foreach(array("primaryMailAddress","alternateAddresses","mailSizeLimit") as $attr){ $smarty->assign("{$attr}ACL", $this->getacl($attr)); $smarty->assign($attr, set_post($this->$attr)); } foreach(array('mailSizeLimit','alternateAddresses') as $feature){ $smarty->assign("{$feature}_isActive", $this->featureEnabled($feature)); } $smarty->assign("useMailSizeLimit", ($this->mailSizeLimit != NULL)); $smarty->assign("memberList", set_post($this->memberList)); $smarty->assign('rpcErrorMessage' , $this->rpcErrorMessage); return($display.$smarty->fetch(get_template_path('GroupwareDistributionList/generic.tpl', TRUE))); } /*! \brief ACL settings */ static function plInfo() { return (array( "plShortName" => _("Distribution list"), "plDescription" => _("Groupware distribution lists"), "plSelfModify" => FALSE, "plDepends" => array("ogroup"), // This plugin depends on "plPriority" => 4, // Position in tabs "plSection" => array("administration"), "plCategory" => array("ogroups"), "plOptions" => array(), "plProvidedAcls" => array( "primaryMailAddress" => _("Mail address"), "mailSizeLimit" => _("Mail size limit"), "alternateAddresses" => _("Alternate mail addresses")) )); } /*! \brief Get posted values and check which are interesting for us. */ function save_object() { if(isset($_POST['retryInit'])){ $this->init(); } if(isset($_POST['DistributionList_posted'])){ if(!isset($_POST['useMailSizeLimit'])) $this->mailSizeLimit = NULL; plugin::save_object(); } } /*! \brief Add given mail address to the list of alternate adresses, * check if this mal address is used, skip addition in this case. */ function addAlternate($address) { if(empty($address)) return; if($this->acl_is_writeable("alternateAddresses")){ $ldap= $this->config->get_ldap_link(); $address= strtolower($address); /* Is this address already assigned in LDAP? */ $ldap->cd ($this->config->current['BASE']); $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)". "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid", "cn")); if ($ldap->count() > 0){ $attrs= $ldap->fetch (); if (!isset($attrs["uid"])) { return ("!".$attrs["cn"][0]); } return ($attrs["uid"][0]); } if (!in_array_strict($address, $this->alternateAddresses)){ $this->alternateAddresses[]= $address; $this->is_modified= TRUE; } sort ($this->alternateAddresses); reset ($this->alternateAddresses); return (""); }else{ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG); } } /*! \brief Removes the distribution list extension from the current * object group. */ function remove_from_parent() { // Do nothing if this asn't an active account before. if(!$this->initially_was_account) return; // Remove distribution list $rpc = $this->config->getRpcHandle(); $rpc->gwDistDel($this->orig_cn); // An error occured abort here if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to remove the distribution list '%s'! Error was: '%s'."), $this->orig_cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } } /*! \brief Saves the distribution list extension for the current * object group. */ function save() { // Cast mailSizeLimit to integer if($this->mailSizeLimit!=NULL){ $this->mailSizeLimit += 0; } // If this is a new account then add it. $rpc = $this->config->getRpcHandle(); if(!$this->initially_was_account){ $rpc->gwDistAdd($this->cn, $this->primaryMailAddress); if(!$rpc->success()){ $message = sprintf(_("Failed to add distribution list '%s'! Error was: '%s'."), $this->cn, $rpc->get_error()); return; } } // Rename distribution list if cn has changed. if($this->cn != $this->orig_cn && $this->initially_was_account){ $rpc->gwDistRename($this->orig_cn, $this->cn); if(!$rpc->success()){ $message = sprintf(_("Failed to rename distribution list '%s' to '%s'! Error was: '%s'."), $this->orig_cn,$this->cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } } // Updated primaryMailAddress value, if needed: // -> the value for 'primaryMailAddress' has changed. if($this->initially_was_account && $this->primaryMailAddress != $this->saved_attributes['primaryMailAddress']){ $rpc->gwDistSetPrimaryMailAddress($this->cn, $this->primaryMailAddress); if(!$rpc->success()){ $message = sprintf(_("Failed to update the primary mail address for distribution list '%s'! Error was: '%s'."), $this->cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } } // Updated mail size limitations, if needed: // -> is a new distribution list or // -> the value for 'mailSizeLimit' has changed. if($this->featureEnabled('mailSizeLimit')){ if(!$this->initially_was_account || $this->mailSizeLimit != $this->saved_attributes['mailSizeLimit']){ $rpc->gwDistSetMailLimit($this->cn, $this->mailSizeLimit); if(!$rpc->success()){ $message = sprintf(_("Failed to update mail size limitations for distribution list '%s'! Error was: '%s'."), $this->cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } } } // Updated alternate mail addresses, if needed: // -> is a new distribution list or // -> the value for 'alternateAddresses' has changed. if($this->featureEnabled('alternateAddresses')){ sort($this->alternateAddresses); sort($this->saved_attributes['alternateAddresses']); $changed = array_differs($this->alternateAddresses,$this->saved_attributes['alternateAddresses']); if(!$this->initially_was_account || $changed){ $rpc->gwDistSetAlternateMailAddresses($this->cn, $this->alternateAddresses); if(!$rpc->success()){ $message = sprintf(_("Failed to update alternate addresses for distribution list '%s'! Error was: '%s'."), $this->cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } } } // Check which object-group member have a valid groupware mail addresses. // We can only add valid groupware extensions as distribution list member. $uids = $this->getOgroupMemberList(); $rpc = $this->config->getRpcHandle(); $verified = $rpc->gwVerifyAcct($uids); $hasExt = array(); if(!$rpc->success()){ $messages[] = sprintf(_("Failed to verify account ids! Error was: '%s'."),$rpc->get_error()); }else{ $hasExt = array(); foreach($verified as $uid => $mail){ if(!empty($mail)) $hasExt[] = $mail; } } // Check for added or removed distribution list members now. $all = array_merge($hasExt, $this->saved_attributes['memberList']); foreach($all as $member){ if(!in_array_strict($member,$hasExt)){ $rpc->gwDistDelMember($this->cn, $member); if(!$rpc->success()){ $message = sprintf(_("Failed to remove member '%s' from distribution list '%s'! Error was: '%s'."), $member, $this->cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } }elseif(!in_array_strict($member,$this->saved_attributes['memberList'])){ $rpc->gwDistAddMember($this->cn, $member); if(!$rpc->success()){ $message = sprintf(_("Failed to add member '%s' to distribution list '%s'! Error was: '%s'."), $member, $this->cn, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } } } } /*! \brief Removes the given mail address from the alternate addresses list */ function delAlternate($addresses) { if($this->acl_is_writeable("alternateAddresses")){ $this->alternateAddresses= array_remove_entries ($addresses,$this->alternateAddresses); $this->is_modified= TRUE; }else{ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses!"), ERROR_DIALOG); } } function check() { $messages = plugin::check(); // Get current object-group name maybe it is invalid for us. if(isset($this->parent->by_object['ogroup']->cn)){ $this->cn = &$this->parent->by_object['ogroup']->cn; } // Validate email address if(!tests::is_email($this->primaryMailAddress)) { $messages[] = msgPool::invalid(_("Mail address"), $this->primaryMailAddress, '', 'example@gonicus.de'); } // Validate email address if($this->featureEnabled('mailSizeLimit')){ if($this->mailSizeLimit != NULL && !is_numeric($this->mailSizeLimit)){ $messages[] = msgPool::invalid(_("Incoming mail size limitation"), $this->mailSizeLimit, '/[0-9]/' ); } } // Check which accounts have valid groupware mail addresses. if(!count($messages)){ $uids = $this->getOgroupMemberList(); $rpc = $this->config->getRpcHandle(); $verified = $rpc->gwVerifyAcct($uids); if(!$rpc->success()){ $messages[] = sprintf(_("Failed to verify account ids! Error was: '%s'."),$rpc->get_error()); }else{ $noExt = array(); foreach($verified as $uid => $mail){ if(empty($mail)) $noExt[] = $uid; } if(count($noExt)){ $message = sprintf(_("The following object group members do not have a valid groupware extension and will be ignored as distribution list members: %s"),msgPool::buildList($noExt)); msg_dialog::display(_("Info"),$message, INFO_DIALOG); } } } return($messages); } } ?> gosa-plugin-groupware-2.7.4/admin/ogroups/GroupwareDistributionList/generic.tpl0000644000175000017500000000452111454631323027114 0ustar cajuscajus {if $alternateAddresses_isActive} {/if}

{t}Groupware{/t}

{t}Mail address{/t}: {render acl=$primaryMailAddressACL} {/render} {if $mailSizeLimit_isActive}
{render acl=$mailSizeLimitACL} {/render} {t}Use incoming mail size limitation{/t} {render acl=$mailSizeLimitACL} {/render} {/if}

{render acl=$alternateAddressesACL}
{/render} {render acl=$alternateAddressesACL} {/render} {render acl=$alternateAddressesACL} {/render} {render acl=$alternateAddressesACL} {/render}
gosa-plugin-groupware-2.7.4/admin/ogroups/GroupwareDistributionList/initFailed.tpl0000644000175000017500000000017511454563631027557 0ustar cajuscajus

{t}Groupware{/t}

{msgPool type=rpcError text=$rpcErrorMessage}   gosa-plugin-groupware-2.7.4/admin/groups/0000755000175000017500000000000011752422556017376 5ustar cajuscajusgosa-plugin-groupware-2.7.4/admin/groups/GroupwareSharedFolder/0000755000175000017500000000000011752422556023634 5ustar cajuscajusgosa-plugin-groupware-2.7.4/admin/groups/GroupwareSharedFolder/class_GroupwareSharedFolder.inc0000644000175000017500000003534011500446003031737 0ustar cajuscajuscn = ""; if(isset($this->attrs['cn'])){ $this->cn = $this->attrs['cn'][0]; } $this->orig_cn = $this->cn; // Initialize the distribution list using the gosa-ng backend $this->init(); } /*! \brief Check whether a feature is enabled or not. * @param The feature name to check for * @return TRUE on success else FALSE */ function featureEnabled($name) { return(isset($this->featuresEnabled[$name]) && $this->featuresEnabled[$name]); } /*! \brief Try to initialize the plugin using a json-rpc connection * to the gosa-ng server. */ function init() { // Detect supported capabilities $rpc = $this->config->getRpcHandle(); $capabilities = $rpc->gwGetCapabilities(); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load supported capabilities from server! Error was: '%s'."), $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } // Detect features we can use $map['folder'] = array("folderList","folderAdd","folderDel","folderExists"); $map['members'] = array("folderGetMembers","folderSetMembers","folderAddMember","folderDelMember"); foreach($map as $name => $required){ $this->featuresEnabled[$name] = TRUE; foreach($required as $func){ $this->featuresEnabled[$name] &= isset($capabilities[$func]) && $capabilities[$func]; } } // If we're creating a new ogroup, then we definately have no extension yet. $this->rpcError = FALSE; $folderList = array(); $is_account = FALSE; if($this->cn == "" || $this->dn == "new"){ $is_account = FALSE; }else{ // Load folders for the given folderPrefix $this->folderPrefix = "shared/{$this->cn}"; $folders = $rpc->gwFolderList($this->folderPrefix); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load folder list! Error was: '%s'."), $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } // We've avalid account, if we've received at least one matching folder. $is_account = count($folders) != 0; // Prepare folders to be used in the folderWidget if($is_account){ $folderList = array(); foreach($folders as $path){ $name = preg_replace("/^.*\//","",$path); $entry = array(); $entry['name'] = $name; $entry['status'] = ''; $entry['acls'] = array(); $acls = array(); $acls = $rpc->gwFolderGetMembers($path); if(!$rpc->success()){ $this->rpcError = TRUE; $this->rpcErrorMessage = $rpc->get_error(); $message = sprintf(_("Failed to load permissions for folder '%s'! Error was: '%s'."), $path,$rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); return; } foreach($acls as $name => $acl){ $entry['acls'][] = array('type' => 'user', 'acl' => $acl, 'name' => $name); } $folderList[$path] = $entry; } } } // We do not have a valid account, use an initial set of folders // to be able to use the folderWidget. // {%cn} will be replaced by the groups cn when save() is called. if(!$is_account){ $this->folderPrefix = "shared/{%cn}"; $intialFolderEntry = array('name' => '{%cn}', 'status' => 'added', 'acls' => array()); $folderList = array(); $folderList[$this->folderPrefix] = $intialFolderEntry; } // Store values as current and initial values (saved_attributes) // to be able to keep track och changes. $this->is_account = $this->initially_was_account = $is_account; $this->saved_attributes = array(); $this->folderList = $this->saved_attributes['folderList'] = $folderList; $this->capabilities = $capabilities; $this->initialized = TRUE; } function execute() { plugin::execute(); // Initialization failed - Display a stripped template which allows // to retry initialization if(!$this->initialized){ $smarty = get_smarty(); $smarty->assign('rpcError' , $this->rpcError); $smarty->assign('rpcErrorMessage' , $this->rpcErrorMessage); return($smarty->fetch(get_template_path('GroupwareSharedFolder/initFailed.tpl', TRUE))); } // Log account access if($this->is_account && !$this->view_logged){ $this->view_logged = TRUE; new log("view","ogroups/".get_class($this),$this->dn); } // Allow to add or remove the distribution list extension if(isset($_POST['modify_state'])){ if($this->is_account && $this->acl_is_removeable()){ $this->is_account= FALSE; }elseif(!$this->is_account && $this->acl_is_createable()){ $this->is_account= TRUE; } } // Show account status-changer if ($this->parent !== NULL){ if ($this->is_account){ $display= $this->show_disable_header(_("Remove shared folder"), msgPool::featuresEnabled(_("Shared folder"))); } else { $display= $this->show_enable_header(_("Create shared folder"), msgPool::featuresDisabled(_("Shared folder"))); return ($display); } } /**************** Folder editor ****************/ if(!$this->FolderWidget){ $this->FolderWidget = new FolderWidget($this->config,$this->folderList, $this->folderPrefix); $this->FolderWidget->setPermissions(GroupwareDefinitions::getPermissions()); $this->FolderWidget->acl_base = $this->acl_base; $this->FolderWidget->acl_category = $this->acl_category; $this->FolderWidget->showButtons(FALSE); } $this->folderList = $this->FolderWidget->save(); $str = $this->FolderWidget->execute(); $this->dialog = $this->FolderWidget->dialogOpened(); return($str); # ONCE WE HAVE MORE FEATURE THAN JUST THE FOLDER SETTINGS, # ENABLE THIS AGAIN AN REMOVE THE ABOVE LINES. # # if(isset($_POST['FolderWidget_cancel'])) $this->FolderWidget = NULL; # if(isset($_POST['FolderWidget_ok'])){ # $this->FolderWidget->save_object(); # $msgs = $this->FolderWidget->check(); # if(count($msgs)){ # msg_dialog::displayChecks($msgs); # }else{ # $this->folderList = $this->FolderWidget->save(); # $this->FolderWidget = NULL; # } # } # if(isset($_POST['configureFolder'])){ # $this->FolderWidget = new FolderWidget($this->config,$this->folderList, $this->folderPrefix); # $this->FolderWidget->setPermissions(GroupwareDefinitions::getPermissions()); # $this->FolderWidget->acl_base = $this->acl_base; # $this->FolderWidget->acl_category = $this->acl_category; # } # $this->dialog = FALSE; # if($this->FolderWidget instanceOf FolderWidget){ # $this->FolderWidget->save_object(); # $this->dialog = TRUE; # return($this->FolderWidget->execute()); # } # /**************** Generate HTML output ****************/ $plInfo = $this->plInfo(); $smarty = get_smarty(); foreach($plInfo['plProvidedAcls'] as $name => $translation){ $smarty->assign("{$name}ACL", $this->getacl($name)); } $smarty->assign('rpcError' , $this->rpcError); $smarty->assign('rpcErrorMessage' , $this->rpcErrorMessage); return($display.$smarty->fetch(get_template_path('GroupwareSharedFolder/generic.tpl', TRUE))); } /*! \brief Get posted values and check which are interesting for us. */ function save_object() { if(isset($_POST['retryInit'])){ $this->init(); } if(isset($_POST['GroupwareSharedFolder_posted'])){ plugin::save_object(); } if($this->FolderWidget) $this->FolderWidget->save_object(); } /*! \brief Removes the distribution list extension for the current * object group. */ function remove_from_parent() { echo "
Remove all folders"; } /*! \brief Saves the distribution list extension for the current * object group. */ function save() { if(!$this->initialized){ echo "Nothing to save, plugin init failed!"; return; } $this->folderList = $this->FolderWidget->save(); $rpc = $this->config->getRpcHandle(); // Walk through folders and perform requested actions foreach($this->folderList as $path => $folder){ // Update folder names for newly created groupware extensions. $path = preg_replace("/\{%cn\}/", $this->cn, $path); $folder['name'] = preg_replace("/\{%cn\}/", $this->cn, $folder['name']); // Remove shared folder. if($folder['status'] == 'removed'){ $rpc->gwFolderDel($path); if(!$rpc->success()){ $message = sprintf(_("Failed to remove shared folder '%s'! Error was: '%s'."), $path, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } echo "
Removed {$path}"; continue; } // Add newly created folders if($folder['status'] == 'added'){ $rpc->gwFolderAdd($path); if(!$rpc->success()){ $message = sprintf(_("Failed to create shared folder '%s'! Error was: '%s'."), $path, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } echo "
Added {$path}"; } // Collect old and new members and their acls, to be able to compare them later. $oldList = $this->saved_attributes['folderList']; $oldAcls = array(); $newAcls = array(); $oldMembers = array(); $newMembers = array(); if(isset($oldList[$path])){ foreach($oldList[$path]['acls'] as $entry){ $oldMembers[] = $entry['name']; $oldAcls[$entry['name']] = $entry['acl']; } } foreach($folder['acls'] as $entry){ $newMembers[] = $entry['name']; $newAcls[$entry['name']] = $entry['acl']; } // Check if member list has changed. if(array_differs($newMembers,$oldMembers) || array_differs($oldAcls, $newAcls)){ $rpc->gwFolderSetMembers($path, $newAcls); if(!$rpc->success()){ $message = sprintf(_("Failed to create shared folder '%s'! Error was: '%s'."), $path, $rpc->get_error()); msg_dialog::display(_("Error"),msgPool::rpcError($message), ERROR_DIALOG); } echo "
Updating members for {$path} "; } } } function check() { $messages = plugin::check(); // Get current object-group name maybe it is invalid for us. if(isset($this->parent->by_object['group']->cn)){ $this->cn = &$this->parent->by_object['group']->cn; } // Check if group name has changed, this is not allowed while a groupware extension is active. if($this->initially_was_account && $this->cn != $this->orig_cn && $this->orig_cn != ""){ $messages[] = sprintf( _("Groups cannot be renamed, while their groupware extension is active, please use the intial name '%s' again!"), $this->orig_cn); } // Merge Folder messages. if($this->FolderWidget instanceOf FolderWidget){ $messages = array_merge($messages,$this->FolderWidget->check()); } return($messages); } /*! \brief ACL settings */ static function plInfo() { return (array( "plShortName" => _("Shared folder"), "plDescription" => _("Groupware shared folder"), "plSelfModify" => FALSE, "plDepends" => array("ogroup"), // This plugin depends on "plPriority" => 4, // Position in tabs "plSection" => array("administration"), "plCategory" => array("groups"), "plOptions" => array(), "plProvidedAcls" => array( "folderList" => _("Shared folder")) )); } } ?> gosa-plugin-groupware-2.7.4/admin/groups/GroupwareSharedFolder/generic.tpl0000644000175000017500000000103211455026400025751 0ustar cajuscajus

{t}Groupware shared folder{/t}

{render acl=$folderListACL} {t}Edit folder list{/t}  {/render}
gosa-plugin-groupware-2.7.4/admin/groups/GroupwareSharedFolder/initFailed.tpl0000644000175000017500000000021311455025746026421 0ustar cajuscajus

{t}Groupware shared folder{/t}

{msgPool type=rpcError text=$rpcErrorMessage}