/** * function __construct * <pre> * Initialize the Class ... * </pre> * @param $sortBy [STRING] the field name to sort list by * @return [void] */ function __construct($sortBy = '') { $searchManager = new RowManager_LanguageManager(); // NOTE: if you need to narrow the field of the search then uncommnet // the following and set the proper search criteria. //$searchManager->setValueByFieldName('module_isCommonLook', '1' ); $searchManager->setSortOrder($sortBy); $this->resultSet = $searchManager->find(); // Now load the labels into an array for quick retrieval of info. // see getLanaguageIDByKey & getLanguageKeyByID $this->setFirst(); while ($item = $this->getNext()) { $this->languageIDList[$item->getCode()] = $item->getID(); $this->languageKeyList[$item->getID()] = $item->getCode(); } }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; $this->template = new Template($path); // store the form action data $this->template->set('formAction', $this->formCallBack); // store the page labels used by this template... // NOTE: use this location to update any label tags ... $userID = $this->itemManager->getUserID(); $this->labels->setLabelTag('[Title]', '[viewerUserID]', $userID); $this->template->setXML('pageLabels', $this->labels->getLabelXML()); // store the field names being displayed $fieldNames = explode(',', page_DeleteViewer::DISPLAY_FIELDS); $this->template->set('dataFieldList', $fieldNames); // store XML Data of item $this->template->setXML('dataItem', $this->itemManager->getXML()); // store language list for display $languageManager = new RowManager_LanguageManager(); $context = new MultilingualManager($this->viewer->getLanguageID()); $bridge = $languageManager->getRowLabelBridge($context); $languageList = $bridge->getListIterator(); $languageArray = $languageList->getDropListArray(); $this->template->set('list_language_id', $languageArray); $isActiveList = array(); $isActiveList['1'] = $this->labels->getLabel('[yes]'); $isActiveList['0'] = $this->labels->getLabel('[no]'); $this->template->set('list_viewer_isActive', $isActiveList); // uncomment this line if you are creating a template for this page //$templateName = 'page_DeleteViewer.php'; // otherwise use the generic admin box template $templateName = 'siteDeleteConf.php'; return $this->template->fetch($templateName); }
/** * function createNewEntry * <pre> * Creates a new table entry in the DB for these objects to manage. * </pre> * @param $doAllowPrimaryKeyUpdate [BOOL] allow insertion of primary key * @param $viewerLanguageID [INTEGER] overwrite languageManager->language_id * with this value * @return [void] */ function createNewEntry($doAllowPrimaryKeyUpdate = false, $viewerLanguageID = -1) { // create a new entry for the dataManager $this->dataManager->createNewEntry(); // use the new Unique ID of the dataManager to create a unique key $key = '[' . $this->dataManager->getKeyField() . $this->dataManager->getID() . ']'; // update the "PrimaryKeyField" value for the new entry $this->values[$this->primaryKeyField] = $this->dataManager->getID(); // now go back and update the dataManager to have this key $this->dataManager->setLabel($key); $this->dataManager->updateDBTable(); // store key in labelManager $this->labelManager->setKey($key); // NOTE: in the case of the site language table, we must manage the // viewerLanguageID seperatly. If this value is passed in, then // update the labelManager's language ID to this value. if ($viewerLanguageID != -1) { $this->labelManager->resetFieldsOfInterest(); $this->labelManager->setLanguageID($viewerLanguageID); } $this->labelManager->createNewEntry(); $currentLanguageID = $this->labelManager->getLanguageID(); $currentLabel = $this->labelManager->getLabel(); $this->labelManager->resetFieldsOfInterest(); // now for each possible language on site $languageManager = new RowManager_LanguageManager(); $languageList = $languageManager->getListIterator(); $languageList->setFirst(); while ($language = $languageList->getNext()) { // make sure it is not the one we just entered if ($language->getID() != $currentLanguageID) { // set the languageID to new language $this->labelManager->setLanguageID($language->getID()); // mark label as untranslated $unXlatedText = '[' . $language->getCode() . ']' . $currentLabel; $this->labelManager->setLabel($unXlatedText); // create new entry // NOTE: here we tell it to ignore the xlation updates // since we don't want our new entrys unmarking existing // xlation entries... $this->labelManager->createNewEntry(false, true); } } }
/** * function createNewEntry * <pre> * Creates a new row entry in the DB table for this object to manage. It * also updates the Xlation tabel to mark the new entry as needing * translation. * </pre> * @param $doAllowPrimaryKeyUpdate [BOOL] allow insertion of primary key * @param $shouldIgnoreXlation [BOOL] allow insertion of primary key * value if present. * @return [void] */ function createNewEntry($doAllowPrimaryKeyUpdate = false, $shouldIgnoreXlation = false) { // make sure label is translated into UnicodeEntities $data = $this->getLabel(); $newData = Unicode_utf8ToUnicodeEntities($data); $this->setLabel($newData); parent::createNewEntry($doAllowPrimaryKeyUpdate); if (!$shouldIgnoreXlation) { $currentPageID = $this->getPageID(); $currentKey = $this->getKey(); $currentLanguageID = $this->getLanguageID(); $xlationManager = new RowManager_XLationManager(); // If there are no other pageID + labelKey entries like this one // then we need to add xlation entries for all other languages. $condition = 'page_id=' . $currentPageID; if ($this->isUniqueFieldValue($currentKey, 'label_key', $condition)) { $xlationManager->setLabelID($this->getID()); // for each other language in site $languageManager = new RowManager_LanguageManager(); $languageList = $languageManager->getListIterator(); $languageList->setFirst(); while ($language = $languageList->getNext()) { $newLanguageID = $language->getID(); if ($newLanguageID != $currentLanguageID) { // Add Xlation Entry $xlationManager->setLanguageID($newLanguageID); $xlationManager->createNewEntry(); } } // next language } else { // Since there are other label id's, then look to see // if the current entry can substitute for an xlation request // for each label with matching PageID & Key $labelManager = new RowManager_MultilingualLabelManager(); $labelManager->setPageID($currentPageID); $labelManager->setKey($currentKey); $labelList = $labelManager->getListIterator(); $labelList->setFirst(); while ($label = $labelList->getNext()) { // delete any xlation entry with current language_id & // matching label_id if ($xlationManager->loadByLabelAndLanguage($label->getID(), $currentLanguageID)) { $xlationManager->deleteEntry(); } } // next label } // end if isUnique } // end if !shouldIgnoreXlation }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Make a new Template object $path = SITE_PATH_TEMPLATES; // Replace $path with the following line if you want to create a // template tailored for this page: //$path = $this->pathModuleRoot.'templates/'; $this->template = new Template($path); // store the Row Manager's XML Node Name $this->template->set('rowManagerXMLNodeName', RowManager_ViewerManager::XML_NODE_NAME); // store the field names being displayed $fieldNames = explode(',', page_AccountList::DISPLAY_FIELDS); $this->template->set('dataFieldList', $fieldNames); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'viewer_id'); // store the link values // $this->linkValues[ 'view' ] = 'add/new/href/data/here'; $this->template->set('linkValues', $this->linkValues); // store the link labels $this->linkLabels['add'] = $this->labels->getLabel('[Add]'); $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]'); $this->linkLabels['del'] = $this->labels->getLabel('[Delete]'); $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]'); // $this->linkLabels[ 'view' ] = 'new link label here'; $this->template->set('linkLabels', $this->linkLabels); // store any additional link Columns // example: $title = $this->labels->getLabel('[title_passWord]'); $columnLabel = $this->labels->getLabel('[change]'); $link = $this->linkValues['passWord']; $fieldName = 'viewer_id'; $this->addLinkColumn($title, $columnLabel, $link, $fieldName); $title = $this->labels->getLabel('[title_access]'); $columnLabel = $this->labels->getLabel('[change]'); $link = $this->linkValues['accessLink']; $fieldName = 'viewer_id'; $this->addLinkColumn($title, $columnLabel, $link, $fieldName); $this->template->set('linkColumns', $this->linkColumns); // store the page labels // NOTE: use this location to update any label tags ... // example: // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->template->setXML('pageLabels', $this->labels->getLabelXML()); // store XML List of Applicants ... $this->template->setXML('dataList', $this->listManager->getXML()); /* * Set up any additional data transfer to the Template here... */ // NOTE: Here we tell the templat to NOT display the Title & Instr // fields. So we can display them in our own template later on... $this->template->set('disableHeading', true); // store language list for display //$languageList = new LanguageList(); $languageManager = new RowManager_LanguageManager(); $seriesKey = moduleAccountAdmin::MULTILINGUAL_SERIES_KEY; $pageKey = $languageManager->getXMLNodeName(); $multiLingualManager = new MultilingualManager($this->viewer->getLanguageID(), $seriesKey, $pageKey); $bridgeManager = new LanguageLabelBridge($languageManager, $multiLingualManager); $languageList = $bridgeManager->getListIterator(); $languageArray = $languageList->getDropListArray(); $this->template->set('list_language_id', $languageArray); $isActiveList = array(); $isActiveList['1'] = $this->labels->getLabel('[yes]'); $isActiveList['0'] = ' '; //$this->labels->getLabel( '[no]' ); $this->template->set('list_viewer_isActive', $isActiveList); $templateName = 'siteDataList.php'; // if you are creating a custom template for this page then // replace $templateName with the following: //$templateName = 'page_AccountList.php'; $pageAccountList = $this->template->fetch($templateName); // Now create an instance of the page_AccountList template // and add the account List to it. $path = $this->pathModuleRoot . 'templates/'; $template = new Template($path); $template->setXML('pageLabels', $this->labels->getLabelXML()); $template->set('pageContent', $pageAccountList); // now add the data for the Account Group JumpList $groupMgr = new RowManager_AccountGroupManager(); $seriesKey = moduleAccountAdmin::MULTILINGUAL_SERIES_KEY; $pageKey = $groupMgr->getXMLNodeName(); $groupMultiLingualManager = new MultilingualManager($this->viewer->getLanguageID(), $seriesKey, $pageKey); $bridgeManager = new RowLabelBridge($groupMgr, $groupMultiLingualManager); $groupList = $bridgeManager->getListIterator(); $jumpLink = $this->linkValues['jumpLink']; $list = $groupList->getDropListArray(null, $jumpLink); $template->set('jumpList', $list); $template->set('accountGroup', $jumpLink . $this->accountgroup_id); // return template data. $templateName = 'page_AccountList.php'; return $template->fetch($templateName); }
/** * function processData * <pre> * Processes the data for this form. * </pre> * @return [void] */ function processData() { // now get list of NEW Groups added to this Account $addedList = array(); for ($indx = 0; $indx < count($this->submittedGroups); $indx++) { $id = $this->submittedGroups[$indx]; // if id not in currentGroupList then add to addList if (!isset($this->currentGroupList[$id])) { $addedList[] = $id; } } // foreach added group $viewerAccessGroup = new RowManager_ViewerAccessGroupManager(); $accessGroupManager = new RowManager_AccessGroupManager(); $adminAccessGroupID = $accessGroupManager->getAdminAccessGroupID(); //print($adminAccessGroupID . "<br>"); for ($indx = 0; $indx < count($addedList); $indx++) { // create new entry $viewerAccessGroup->createNewEntry(); // load values $values = array(); $values['viewer_id'] = $this->viewer_id; $values['accessgroup_id'] = $addedList[$indx]; $viewerAccessGroup->loadFromArray($values); // update DB Table $viewerAccessGroup->updateDBTable(); //add to table accountadmin_accountadminaccess if acces group is adminAccesGroup if ($values['accessgroup_id'] == $adminAccessGroupID) { $aam = new RowManager_AccountAdminAccessManager(); $aam->setViewerID($this->viewer_id); $aam->setGroupPrivilege(); $aam->createNewEntry(); } } // next group $languageManager = new RowManager_LanguageManager(); $languageList = $languageManager->getListIterator(); $languageList->setFirst(); while ($language = $languageList->getNext()) { $navbar = new RowManager_NavBarCacheManager(); $navbar->loadByViewerID($this->viewer_id, $language->getID()); if ($navbar->getID() != -1) { $navbar->setCacheInvalid(); $navbar->updateDBTable(); } } // get list of DELETED Groups from this account $deletedList = array(); foreach ($this->currentGroupList as $key => $value) { if (!in_array($key, $this->submittedGroups)) { $deletedList[] = $key; } } // foreach deleted group for ($indx = 0; $indx < count($deletedList); $indx++) { // if we can load a manager for this account with this group then if ($viewerAccessGroup->loadByViewerAccessGroup($this->viewer_id, $deletedList[$indx])) { // delete $viewerAccessGroup->deleteEntry(); if ($deletedList[$indx] == $adminAccessGroupID) { $aam = new RowManager_AccountAdminAccessManager(); $aam->setViewerID($this->viewer_id); //$aam->setGroupPrivilege(); //print("before delete"); $aam->deleteEntry(); } } } // next group // update currentGroupList with submittedGroupList $groupList = new ViewerAccessGroupList($this->viewer_id, $this->sortBy); $this->currentGroupList = $groupList->getAccessGroupArray(); }