/** * Returns a textual representation of the formentries' value. * May contain html, but should be stripped down to text-only. * * @return string */ public function getValueAsText() { if (validateSystemid($this->getStrValue())) { $objUser = new class_module_user_user($this->getStrValue()); return $objUser->getStrDisplayName(); } return ""; }
/** * Converts the passed value to a formatted value. * In most scenarios, the value is written directly to the template. * * @param mixed $strValue * * @return string */ public function format($strValue) { if (validateSystemid($strValue)) { $objUser = new class_module_user_user($strValue); return $objUser->getStrDisplayName(); } return $strValue; }
/** * Removes the elements / modules handled by the current installer. * Use the reference param to add a human readable logging. * * @param string &$strReturn * * @return bool */ public function remove(&$strReturn) { //remove the workflow if (class_module_system_module::getModuleByName("workflows") !== null) { foreach (class_module_workflows_workflow::getWorkflowsForClass("class_workflow_ldap_sync") as $objOneWorkflow) { if (!$objOneWorkflow->deleteObjectFromDatabase()) { $strReturn .= "Error deleting workflow, aborting.\n"; return false; } } $objHandler = class_module_workflows_handler::getHandlerByClass("class_workflow_ldap_sync"); if (!$objHandler->deleteObjectFromDatabase()) { $strReturn .= "Error deleting workflow handler, aborting.\n"; return false; } } //fetch associated users foreach ($this->objDB->getPArray("SELECT * FROM " . _dbprefix_ . "user_ldap", array()) as $arrOneRow) { $objOneUser = new class_module_user_user($arrOneRow["user_ldap_id"]); echo "Deleting ldap user " . $objOneUser->getStrDisplayName() . "...\n"; $objOneUser->deleteObjectFromDatabase(); } //fetch associated groups foreach ($this->objDB->getPArray("SELECT * FROM " . _dbprefix_ . "user_group_ldap", array()) as $arrOneRow) { $objOneUser = new class_module_user_group($arrOneRow["group_ldap_id"]); echo "Deleting ldap group " . $objOneUser->getStrDisplayName() . "...\n"; $objOneUser->deleteObjectFromDatabase(); } //delete the module-node $strReturn .= "Deleting the module-registration...\n"; $objModule = class_module_system_module::getModuleByName($this->objMetadata->getStrTitle(), true); if (!$objModule->deleteObjectFromDatabase()) { $strReturn .= "Error deleting module, aborting.\n"; return false; } //delete the tables foreach (array("user_group_ldap", "user_ldap") as $strOneTable) { $strReturn .= "Dropping table " . $strOneTable . "...\n"; if (!$this->objDB->_pQuery("DROP TABLE " . $this->objDB->encloseTableName(_dbprefix_ . $strOneTable) . "", array())) { $strReturn .= "Error deleting table, aborting.\n"; return false; } } return true; }
/** * @return string */ public function getStrUsername() { $objUser = new class_module_user_user($this->getStrUserId()); return $objUser->getStrDisplayName(); }
/** * Returns a list of users belonging to a specified group * * @param class_admin_formgenerator $objForm * * @return string * @permissions edit */ protected function actionGroupMember(class_admin_formgenerator $objForm = null) { $strReturn = ""; if ($this->getSystemid() != "") { $objGroup = new class_module_user_group($this->getSystemid()); //validate possible blocked groups $bitRenderEdit = $this->isGroupEditable($objGroup); $objSourceGroup = $objGroup->getObjSourceGroup(); $strReturn .= $this->objToolkit->formHeadline($this->getLang("group_memberlist") . "\"" . $objGroup->getStrName() . "\""); $objUsersources = new class_module_user_sourcefactory(); if ($objUsersources->getUsersource($objGroup->getStrSubsystem())->getMembersEditable() && $bitRenderEdit) { if ($objForm == null) { $objForm = $this->getGroupMemberForm($objGroup); } $arrFolder = $this->objToolkit->getLayoutFolder($objForm->renderForm(getLinkAdminHref($this->getArrModule("modul"), "addUserToGroup")), $this->getLang("group_add_user")); $strReturn .= $this->objToolkit->getFieldset($arrFolder[1], $arrFolder[0]); } $objIterator = new class_array_section_iterator($objSourceGroup->getNumberOfMembers()); $objIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1)); $objIterator->setArraySection($objSourceGroup->getUserIdsForGroup($objIterator->calculateStartPos(), $objIterator->calculateEndPos())); $strReturn .= $this->objToolkit->listHeader(); $intI = 0; foreach ($objIterator as $strSingleMemberId) { $objSingleMember = new class_module_user_user($strSingleMemberId); $strAction = ""; if ($objUsersources->getUsersource($objGroup->getStrSubsystem())->getMembersEditable() && $bitRenderEdit) { $strAction .= $this->objToolkit->listDeleteButton($objSingleMember->getStrUsername() . " (" . $objSingleMember->getStrForename() . " " . $objSingleMember->getStrName() . ")", $this->getLang("mitglied_loeschen_frage"), class_link::getLinkAdminHref($this->getArrModule("modul"), "groupMemberDelete", "&groupid=" . $objGroup->getSystemid() . "&userid=" . $objSingleMember->getSystemid())); } $strReturn .= $this->objToolkit->genericAdminList($objSingleMember->getSystemid(), $objSingleMember->getStrDisplayName(), getImageAdmin("icon_user"), $strAction, $intI++); } $strReturn .= $this->objToolkit->listFooter() . $this->objToolkit->getPageview($objIterator, "user", "groupMember", "systemid=" . $this->getSystemid()); } return $strReturn; }
/** * Returns the name to be used when rendering the current object, e.g. in admin-lists. * * @return string */ public function getStrDisplayName() { if (validateSystemid($this->getStrUserId())) { $objUser = new class_module_user_user($this->getStrUserId()); $strName = $objUser->getStrDisplayName(); } else { $strName = $this->getStrEmail() . ($this->getStrLastname() != "" || $this->getStrForename() != "" ? $this->getStrLastname() . ", " . $this->getStrForename() : ""); } if ($this->getIntParticipationStatus() == 2) { $strName = "<span style='text-decoration: line-through'>{$strName}</span>"; } if ($this->getIntParticipationStatus() == 3) { $strName = "<span style='font-style: italic'>{$strName}</span>"; } return $strName; }
/** * @param string $strTargetURI If you pass null, no form-tags will be rendered. * @param int $intButtonConfig a list of buttons to attach to the end of the form. if you need more then the obligatory save-button, * pass them combined by a bitwise or, e.g. class_admin_formgenerator::BIT_BUTTON_SAVE | class_admin_formgenerator::$BIT_BUTTON_CANCEL * * @throws class_exception * @return string */ public function renderForm($strTargetURI, $intButtonConfig = 2) { $strReturn = ""; //add a hidden systemid-field if ($this->objSourceobject != null) { $objField = new class_formentry_hidden($this->strFormname, "systemid"); $objField->setStrEntryName("systemid")->setStrValue($this->objSourceobject->getSystemid())->setObjValidator(new class_systemid_validator()); $this->addField($objField); } $objToolkit = class_carrier::getInstance()->getObjToolkit("admin"); if ($strTargetURI !== null) { $strReturn .= $objToolkit->formHeader($strTargetURI, "", $this->strFormEncoding, $this->strOnSubmit); } $strReturn .= $objToolkit->getValidationErrors($this); $strHidden = ""; foreach ($this->arrFields as $objOneField) { if (in_array($objOneField->getStrEntryName(), $this->arrHiddenElements)) { $strHidden .= $objOneField->renderField(); } else { $strReturn .= $objOneField->renderField(); } } if ($strHidden != "") { $strReturn .= $objToolkit->formOptionalElementsWrapper($strHidden, $this->strHiddenGroupTitle, $this->bitHiddenElementsVisible); } if ($intButtonConfig & self::BIT_BUTTON_SUBMIT) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_submit", "system"), "submitbtn"); } if ($intButtonConfig & self::BIT_BUTTON_SAVE) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_save", "system"), "submitbtn"); } if ($intButtonConfig & self::BIT_BUTTON_CANCEL) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_cancel", "system"), "cancelbtn"); } if ($intButtonConfig & self::BIT_BUTTON_CLOSE) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_close", "system"), "closebtn"); } if ($intButtonConfig & self::BIT_BUTTON_DELETE) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_delete", "system"), "deletebtn"); } if ($intButtonConfig & self::BIT_BUTTON_RESET) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_reset", "system"), "reset", "", "cancelbutton"); } if ($intButtonConfig & self::BIT_BUTTON_CONTINUE) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_continue", "system"), "continuebtn"); } if ($intButtonConfig & self::BIT_BUTTON_BACK) { $strReturn .= $objToolkit->formInputSubmit(class_lang::getInstance()->getLang("commons_back", "system"), "backbtn"); } if ($strTargetURI !== null) { $strReturn .= $objToolkit->formClose(); } if (count($this->arrFields) > 0) { reset($this->arrFields); do { $objField = current($this->arrFields); if (!$objField instanceof class_formentry_hidden && !$objField instanceof class_formentry_plaintext && !$objField instanceof class_formentry_headline && !$objField instanceof class_formentry_divider) { $strReturn .= $objToolkit->setBrowserFocus($objField->getStrEntryName()); break; } } while (next($this->arrFields) !== false); } //lock the record to avoid multiple edit-sessions - if in edit mode if ($this->objSourceobject != null && method_exists($this->objSourceobject, "getLockManager")) { $bitSkip = false; if ($this->getField("mode") != null && $this->getField("mode")->getStrValue() == "new") { $bitSkip = true; } if (!$bitSkip && !validateSystemid($this->objSourceobject->getSystemid())) { $bitSkip = true; } if (!$bitSkip) { if ($this->objSourceobject->getLockManager()->isAccessibleForCurrentUser()) { $this->objSourceobject->getLockManager()->lockRecord(); } else { $objUser = new class_module_user_user($this->objSourceobject->getLockManager()->getLockId()); throw new class_exception("Current record is already locked by user '" . $objUser->getStrDisplayName() . "'.\nCannot be locked for the current user", class_exception::$level_ERROR); } } } return $strReturn; }
/** * Returns the name of the user who last edited the record * * @param string $strSystemid * * @throws class_exception * @return string */ public function getLastEditUser($strSystemid = "") { if ($strSystemid != "") { throw new class_exception("unsupported param @ " . __METHOD__, class_exception::$level_FATALERROR); } if (validateSystemid($this->getStrLmUser())) { $objUser = new class_module_user_user($this->getStrLmUser()); return $objUser->getStrDisplayName(); } else { return "System"; } }
/** * Creates a summary of the message * * @return string */ protected function actionView() { /** @var class_module_messaging_message $objMessage */ $objMessage = class_objectfactory::getInstance()->getObject($this->getSystemid()); //different permission handlings if ($objMessage !== null && !$objMessage->rightView()) { return $this->strOutput = $this->getLang("commons_error_permissions"); } else { if ($objMessage == null) { $strText = $this->getLang("message_not_existing"); $strOk = $this->getLang("commons_ok"); $strLink = class_link::getLinkAdminHref($this->getArrModule("modul"), "list"); $strCore = class_resourceloader::getInstance()->getCorePathForModule("module_v4skin"); $strMessage = "<script type='text/javascript'>\n KAJONA.admin.loader.loadFile('_webpath_{$strCore}/module_v4skin/admin/skins/kajona_v4/js/kajona_dialog.js', function() {\n jsDialog_1.setTitle(' ');\n jsDialog_1.setContent('{$strText}', '{$strOk}', '{$strLink}'); jsDialog_1.init();\n \$('#'+jsDialog_1.containerId+'_cancelButton').css('display', 'none');\n });\n </script>"; return $strMessage; } } if ($objMessage->getStrUser() == $this->objSession->getUserID()) { $strReturn = ""; if (!$objMessage->getBitRead()) { $objMessage->setBitRead(true); $objMessage->updateObjectToDb(); } $objSender = new class_module_user_user($objMessage->getStrSenderId()); $strReference = ""; if (validateSystemid($objMessage->getStrMessageRefId())) { $objRefMessage = new class_module_messaging_message($objMessage->getStrMessageRefId()); $strReference = $objRefMessage->getStrDisplayName(); if ($objRefMessage->rightView()) { $strReference = getLinkAdmin($this->getArrModule("modul"), "view", "&systemid=" . $objRefMessage->getSystemid(), $strReference, "", "", false); } } $arrMetaData = array(array($this->getLang("message_subject"), $objMessage->getStrTitle()), array($this->getLang("message_date"), dateToString($objMessage->getObjDate())), array($this->getLang("message_type"), $objMessage->getObjMessageProvider()->getStrName()), array($this->getLang("message_sender"), $objSender->getStrDisplayName()), array($this->getLang("message_reference"), $strReference)); $strReturn .= $this->objToolkit->dataTable(null, $arrMetaData); $strBody = nl2br($objMessage->getStrBody()); $strBody = replaceTextLinks($strBody); $strReturn .= $this->objToolkit->getFieldset($objMessage->getStrTitle(), $this->objToolkit->getTextRow($strBody)); return $strReturn; } else { return $this->getLang("commons_error_permissions"); } }
/** * Renders a list of records currently locked * * @permissions right1 * @return string * @autoTestable */ protected function actionLockedRecords() { $objArraySectionIterator = new class_array_section_iterator(class_lockmanager::getLockedRecordsCount()); $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1)); $objArraySectionIterator->setArraySection(class_lockmanager::getLockedRecords($objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos())); $strReturn = ""; if (!$objArraySectionIterator->valid()) { $strReturn .= $this->getLang("commons_list_empty"); } $strReturn .= $this->objToolkit->listHeader(); foreach ($objArraySectionIterator as $objOneRecord) { $strImage = ""; if ($objOneRecord instanceof interface_admin_listable) { $strImage = $objOneRecord->getStrIcon(); if (is_array($strImage)) { $strImage = class_adminskin_helper::getAdminImage($strImage[0], $strImage[1]); } else { $strImage = class_adminskin_helper::getAdminImage($strImage); } } $strActions = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "lockedRecords", "&unlockid=" . $objOneRecord->getSystemid(), $this->getLang("action_unlock_record"), $this->getLang("action_unlock_record"), "icon_lockerOpen")); $objLockUser = new class_module_user_user($objOneRecord->getLockManager()->getLockId()); $strReturn .= $this->objToolkit->genericAdminList($objOneRecord->getSystemid(), $objOneRecord instanceof interface_model ? $objOneRecord->getStrDisplayName() : get_class($objOneRecord), $strImage, $strActions, 0, get_class($objOneRecord), $this->getLang("locked_record_info", array(dateToString(new class_date($objOneRecord->getIntLockTime())), $objLockUser->getStrDisplayName()))); } $strReturn .= $this->objToolkit->listFooter(); $strReturn .= $this->objToolkit->getPageview($objArraySectionIterator, "system", "lockedRecords"); return $strReturn; }
/** * Returns a regular text-input field. * The param $strValue expects a system-id. * The element creates two fields: * a text-field, and a hidden field for the selected systemid. * The hidden field is names as $strName, appended by "_id". * If you want to filter the list for users having at least view-permissions on a given systemid, you may pass the id as an optional param. * * @param string $strName * @param string $strTitle * @param string $strValue * @param string $strClass * @param bool $bitUser * @param bool $bitGroups * @param bool $bitBlockCurrentUser * @param string $arrValidateSystemid If you want to check the view-permissions for a given systemid, pass the id here * * @return string * @throws class_exception */ public function formInputUserSelector($strName, $strTitle = "", $strValue = "", $strClass = "", $bitUser = true, $bitGroups = false, $bitBlockCurrentUser = false, array $arrValidateSystemid = null) { $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "input_userselector"); $strUserName = ""; $strUserId = ""; //value is a systemid if (validateSystemid($strValue)) { $objUser = new class_module_user_user($strValue); $strUserName = $objUser->getStrDisplayName(); $strUserId = $strValue; } $strCheckIds = json_encode($arrValidateSystemid); $arrTemplate = array(); $arrTemplate["name"] = $strName; $arrTemplate["value"] = htmlspecialchars($strUserName, ENT_QUOTES, "UTF-8", false); $arrTemplate["value_id"] = htmlspecialchars($strUserId, ENT_QUOTES, "UTF-8", false); $arrTemplate["title"] = $strTitle; $arrTemplate["class"] = $strClass; $arrTemplate["opener"] = class_link::getLinkAdminDialog("user", "userBrowser", "&form_element={$strName}&checkid={$strCheckIds}" . ($bitGroups ? "&allowGroup=1" : "") . ($bitBlockCurrentUser ? "&filter=current" : ""), class_carrier::getInstance()->getObjLang()->getLang("user_browser", "user"), class_carrier::getInstance()->getObjLang()->getLang("user_browser", "user"), "icon_externalBrowser", class_carrier::getInstance()->getObjLang()->getLang("user_browser", "user")); $strResetIcon = class_link::getLinkAdminManual("href=\"#\" onclick=\"document.getElementById('" . $strName . "').value='';document.getElementById('" . $strName . "_id').value='';return false;\"", "", class_carrier::getInstance()->getObjLang()->getLang("user_browser_reset", "user"), "icon_delete"); $arrTemplate["opener"] .= " " . $strResetIcon; $strName = uniStrReplace(array("[", "]"), array("\\\\[", "\\\\]"), $strName); $arrTemplate["ajaxScript"] = "\r\n\t <script type=\"text/javascript\">\r\n \$(function() {\r\n\r\n var objConfig = new KAJONA.v4skin.defaultAutoComplete();\r\n objConfig.source = function(request, response) {\r\n \$.ajax({\r\n url: '" . getLinkAdminXml("user", "getUserByFilter") . "',\r\n type: 'POST',\r\n dataType: 'json',\r\n data: {\r\n filter: request.term,\r\n user: "******"'true'" : "'false'") . ",\r\n group: " . ($bitGroups ? "'true'" : "'false'") . ",\r\n block: " . ($bitBlockCurrentUser ? "'current'" : "''") . ",\r\n checkid: '" . $strCheckIds . "'\r\n },\r\n success: response\r\n });\r\n };\r\n\r\n\r\n \$('#" . $strName . "').autocomplete(objConfig).data( 'ui-autocomplete' )._renderItem = function( ul, item ) {\r\n return \$( '<li></li>' )\r\n .data('ui-autocomplete-item', item)\r\n .append( '<a class=\\'ui-autocomplete-item\\' >'+item.icon+item.title+'</a>' )\r\n .appendTo( ul );\r\n } ;\r\n });\r\n\t </script>\r\n "; return $this->objTemplate->fillTemplate($arrTemplate, $strTemplateID, true); }