/** * Works like javascript function but uses a module directory instead * @see Layout::getJavascript * @param string $module * @param string $directory * @param array $data * @param boolean $wrap_header If true, wrap the contents of head.js with <script> tags * @param boolean $wrap_body If true, wrap the contents of body.js with <script> tags * @return string */ function javascriptMod($module, $directory, $data = null, $wrap_header = false, $wrap_body = false) { if (preg_match('/\\W/', $module)) { return false; } $root_directory = "mod/{$module}/"; return Layout::getJavascript($directory, $data, $root_directory, $wrap_header, $wrap_body); }
public function get() { if (empty($this->type)) { return null; } $formData['NAME'] = $this->name; $formData['ID'] = $this->id; $formData['VALUE'] = $this->data; $formData['LIMITED'] = $this->limited; if ($this->width > 200) { $formData['WIDTH'] = (int) $this->width; } if ($this->height > 200) { $formData['HEIGHT'] = (int) $this->height; } return Layout::getJavascript('editors/' . $this->type, $formData); }
public function show() { /* if(!Current_User::allow('hms', 'email_hall')){ PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to message halls.'); } */ PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); $submitCmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $form = new PHPWS_Form('select_halls_to_email'); $submitCmd->initForm($form); javascript('jquery_ui'); $cmd = CommandFactory::getCommand('ShowHallNotificationEdit'); $form = new PHPWS_Form("select_halls"); $cmd->initForm($form); $form->addSubmit('submit', 'Submit'); $form->setExtra('submit', 'onclick="submitHallList();"'); $tpl = $form->getTemplate(); Layout::addPageTitle("Hall Notification Select"); return PHPWS_Template::process($tpl, 'hms', 'admin/messages.tpl') . Layout::getJavascript("modules/hms/hall_expander", array("DIV" => "hall_list", "FORM" => "select_halls")); }
public function getModuleJavascript($module, $script_name, $data = NULL) { $base = "mod/{$module}/"; $dir_check = "/javascript/{$script_name}"; if (!is_dir(PHPWS_SOURCE_DIR . $base . $dir_check)) { return FALSE; } return Layout::getJavascript($script_name, $data, $base); }
public function getJSView($thumbnail = false, $link_override = null) { if ($link_override) { $values['label'] = $link_override; } else { if ($thumbnail) { $values['label'] = $this->getThumbnail(); } else { $values['label'] = sprintf('<img src="%smod/filecabinet/img/viewmag+.png" title="%s" />', PHPWS_SOURCE_HTTP, dgettext('filecabinet', 'View full image')); } } $size = $this->popupSize(); $values['address'] = $this->popupAddress(); $values['width'] = $size[0]; $values['height'] = $size[1]; $values['window_name'] = 'multimedia_view'; return Layout::getJavascript('open_window', $values); }
public function getPagerByRoomTags() { $tags = array(); $tags['BEDROOM'] = $this->bedroom_label; $tags['BED_LETTER'] = $this->getLink(); $tags['ASSIGNED_TO'] = $this->get_assigned_to_link(); $tags['RA'] = $this->ra_roommate ? 'Yes' : 'No'; $this->loadAssignment(); if ($this->_curr_assignment == NULL && Current_User::allow('hms', 'bed_structure') && UserStatus::isAdmin()) { $deleteBedCmd = CommandFactory::getCommand('DeleteBed'); $deleteBedCmd->setBedId($this->id); $deleteBedCmd->setRoomId($this->room_id); $confirm = array(); $confirm['QUESTION'] = 'Are you sure want to delete bed ' . $this->bed_letter . '?'; $confirm['ADDRESS'] = $deleteBedCmd->getURI(); $confirm['LINK'] = '<i class="fa fa-trash close"></i>'; $tags['DELETE'] = Layout::getJavascript('confirm', $confirm); } return $tags; }
public static function listModules($type) { Layout::addStyle('boost'); $allow_update = true; $core_update_needed = false; $dir_content = array(); if (!PHPWS_Boost::checkDirectories($dir_content)) { $tpl['DIRECTORIES'] = implode('<br />', $dir_content); $allow_update = false; } $core_mods = PHPWS_Core::coreModList(); $installed_mods = PHPWS_Core::installModList(); $dir_mods = PHPWS_Boost::getAllMods(); if ($type == 'core_mods') { $allowUninstall = false; $modList = $core_mods; $core_file = new PHPWS_Module('core'); $core_db = new PHPWS_Module('core', false); $template['TITLE'] = $core_db->proper_name; $template['VERSION'] = $core_db->version; if (isset($_SESSION['Boost_Needs_Update']['core'])) { $link_title = $_SESSION['Boost_Needs_Update']['core']; if (version_compare($core_file->version, $_SESSION['Boost_Needs_Update']['core'], '<')) { $link_title = sprintf(dgettext('boost', '%s - New'), $link_title); } } else { $link_title = dgettext('boost', 'Check'); } if ($core_file->isAbout()) { $address = PHPWS_Text::linkAddress('boost', array('action' => 'aboutView', 'aboutmod' => $core_file->title), true); $aboutView = array('label' => dgettext('boost', 'About'), 'address' => $address); $template['ABOUT'] = Layout::getJavascript('open_window', $aboutView); } $link_command['opmod'] = 'core'; $link_command['action'] = 'check'; if (ini_get('allow_url_fopen')) { $template['LATEST'] = PHPWS_Text::secureLink($link_title, 'boost', $link_command); } else { $template['LATEST'] = dgettext('boost', 'Check disabled'); } if (version_compare($core_db->version, $core_file->version, '<')) { if ($core_file->checkDependency()) { if ($allow_update) { $link_command['action'] = 'update_core'; $core_links[] = PHPWS_Text::secureLink(dgettext('boost', 'Update'), 'boost', $link_command); } else { $core_links[] = dgettext('boost', 'Update'); } $tpl['WARNING'] = dgettext('boost', 'The Core requires updating! You should do so before any modules.'); $core_update_needed = true; } else { $link_command['action'] = 'show_dependency'; $core_links[] = PHPWS_Text::secureLink(dgettext('boost', 'Missing dependency'), 'boost', $link_command); } $template['VERSION'] = sprintf('%s > %s', $core_db->version, $core_file->version); $template['COMMAND'] = implode(' | ', $core_links); } else { $template['COMMAND'] = dgettext('boost', 'None'); } $template['ROW'] = 1; $tpl['mod-row'][] = $template; } else { $allowUninstall = true; $modList = array_diff($dir_mods, $core_mods); } $tpl['TITLE_LABEL'] = dgettext('boost', 'Module Title'); $tpl['COMMAND_LABEL'] = dgettext('boost', 'Commands'); $tpl['ABOUT_LABEL'] = dgettext('boost', 'More information'); $tpl['VERSION_LABEL'] = dgettext('boost', 'Current version'); if ($type == 'core_mods' && Current_User::isDeity() && DEITIES_CAN_UNINSTALL) { $tpl['WARNING'] = dgettext('boost', 'WARNING: Only deities can uninstall core modules. Doing so may corrupt your installation!'); } if (empty($modList)) { return dgettext('boost', 'No modules available.'); } sort($modList); $count = 1; foreach ($modList as $title) { $links = array(); $template = $link_command = NULL; $link_command['opmod'] = $title; $mod = new PHPWS_Module($title); if (!$mod->isFullMod()) { continue; } $proper_name = $mod->getProperName(); if (!isset($proper_name)) { $proper_name = $title; } $template['VERSION'] = $mod->version; $template['TITLE'] = $proper_name; $template['ROW'] = $count % 2 + 1; $version_check = $mod->getVersionHttp(); if (isset($version_check)) { if (isset($_SESSION['Boost_Needs_Update'][$mod->title])) { $link_title = $_SESSION['Boost_Needs_Update'][$mod->title]; if (version_compare($mod->version, $_SESSION['Boost_Needs_Update'][$mod->title], '<')) { $link_title = sprintf(dgettext('boost', '%s - New'), $link_title); } } else { $link_title = dgettext('boost', 'Check'); } $link_command['action'] = 'check'; if (ini_get('allow_url_fopen')) { $template['LATEST'] = PHPWS_Text::secureLink($link_title, 'boost', $link_command); } else { $template['LATEST'] = dgettext('boost', 'Check disabled'); } } if (!$mod->isInstalled()) { if ($mod->checkDependency()) { $link_title = dgettext('boost', 'Install'); $link_command['action'] = 'install'; } else { $link_title = dgettext('boost', 'Missing dependency'); $link_command['action'] = 'show_dependency'; } if ($GLOBALS['Boost_Ready']) { if (javascriptEnabled()) { $js['width'] = 640; $js['height'] = 480; $js['address'] = PHPWS_Text::linkAddress('boost', $link_command, true); $js['label'] = $link_title; $links[] = javascript('open_window', $js); unset($js); } else { $links[] = PHPWS_Text::secureLink($link_title, 'boost', $link_command); } } else { $links[] =& $link_title; } } else { if ($mod->needsUpdate()) { $db_mod = new PHPWS_Module($mod->title, false); $template['VERSION'] = $db_mod->version . ' > ' . $mod->version; if ($mod->checkDependency()) { if ($title == 'boost' && !$core_update_needed) { $tpl['WARNING'] = dgettext('boost', 'Boost requires updating! You should do so before any other module!'); } $link_title = dgettext('boost', 'Update'); $link_command['action'] = 'update'; } else { $link_title = dgettext('boost', 'Missing dependency'); $link_command['action'] = 'show_dependency'; } if ($allow_update) { $js['width'] = 640; $js['height'] = 480; $js['address'] = PHPWS_Text::linkAddress('boost', $link_command, true); $js['label'] = $link_title; $links[] = javascript('open_window', $js); unset($js); } else { $links[] =& $link_title; } } if ($type != 'core_mods' || Current_User::isDeity() && DEITIES_CAN_UNINSTALL) { if ($dependents = $mod->isDependedUpon()) { $link_command['action'] = 'show_depended_upon'; $depend_warning = sprintf(dgettext('boost', 'This module is depended upon by: %s'), implode(', ', $dependents)); $links[] = PHPWS_Text::secureLink(dgettext('boost', 'Depended upon'), 'boost', $link_command, NULL, $depend_warning); } else { $links[] = PHPWS_Boost::uninstallLink($title); } } } if ($mod->isAbout()) { $address = PHPWS_Text::linkAddress('boost', array('action' => 'aboutView', 'aboutmod' => $mod->title), true); $aboutView = array('label' => dgettext('boost', 'About'), 'address' => $address); $template['ABOUT'] = Layout::getJavascript('open_window', $aboutView); } if (!empty($links)) { $template['COMMAND'] = implode(' | ', $links); } else { $template['COMMAND'] = dgettext('boost', 'None'); } $tpl['mod-row'][] = $template; $count++; } $tpl['OLD_MODS'] = Boost_Form::oldModList(); if (ini_get('allow_url_fopen')) { $tpl['CHECK_FOR_UPDATES'] = PHPWS_Text::secureLink(dgettext('boost', 'Check all'), 'boost', array('action' => 'check_all', 'tab' => $type)); } else { $tpl['CHECK_FOR_UPDATES'] = dgettext('boost', 'Server configuration prevents version checking.'); } $tpl['LATEST_LABEL'] = dgettext('boost', 'Latest version'); $release_version = PHPWS_Core::releaseVersion(); $tpl['PHPWS_VERSION'] = $release_version; $result = PHPWS_Template::process($tpl, 'boost', 'module_list.tpl'); return $result; }
public function view($pin_mode = FALSE, $admin_icon = TRUE) { $edit = $opt = null; if (Current_User::allow('block', 'edit_block', $this->id)) { $img = '<i class="fa fa-edit" title="' . dgettext('block', 'Edit block') . '"></i>'; $edit = PHPWS_Text::secureLink($img, 'block', array('block_id' => $this->id, 'action' => 'edit')); if (!empty($this->_pin_key) && $pin_mode) { $link['action'] = 'lock'; $link['block_id'] = $this->id; $link['key_id'] = $this->_pin_key->id; $img = '<img src="' . PHPWS_SOURCE_HTTP . '/mod/block/img/pin.png" />'; $opt = PHPWS_Text::secureLink($img, 'block', $link); } elseif (!empty($this->_pin_key) && $admin_icon) { $vars['action'] = 'remove'; $vars['block_id'] = $this->id; $vars['key_id'] = $this->_pin_key->id; $js_var['ADDRESS'] = PHPWS_Text::linkAddress('block', $vars, TRUE); $js_var['QUESTION'] = dgettext('block', 'Are you sure you want to remove this block from this page?'); $js_var['LINK'] = "<i class='fa fa-remove-circle' title='" . dgettext('block', 'Remove block from page') . "'></i>"; $opt = Layout::getJavascript('confirm', $js_var); } } $link['block_id'] = $this->id; $template = array('CONTENT' => $this->getContent(), 'OPT' => $opt, 'EDIT' => $edit, 'ID' => $this->getId()); if (!$this->hide_title) { $template['TITLE'] = $this->getTitle(); } if ($this->hide_narrow) { $template['HIDDEN'] = ' hidden-xs'; } return PHPWS_Template::process($template, 'block', 'default.tpl'); }
public function getJSView($thumbnail = FALSE, $link_override = null) { if ($link_override) { $values['label'] = $link_override; } else { if ($thumbnail) { $values['label'] = $this->getThumbnail(); } else { $values['label'] = sprintf('<img src="%smod/filecabinet/img/viewmag+.png" title="%s" />', PHPWS_SOURCE_HTTP, dgettext('filecabinet', 'View full image')); } } $values['address'] = $this->popupAddress(); $values['width'] = FC_MAX_IMAGE_POPUP_WIDTH + 50; $values['height'] = FC_MAX_IMAGE_POPUP_HEIGHT + 100; $values['window_name'] = 'image_view'; return Layout::getJavascript('open_window', $values); }
function getHistoryTpl() { $vars['page'] = $this->getTitle(FALSE); $vars['page_op'] = 'viewold'; $vars['id'] = $this->getId(); $links[] = PHPWS_Text::moduleLink(dgettext('wiki', 'View'), 'wiki', $vars); if ((Current_User::allow('wiki', 'edit_page') || PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) && $this->getAllowEdit() && !$this->getVrCurrent()) { $vars['page_op'] = 'restore'; $links[] = PHPWS_Text::secureLink(dgettext('wiki', 'Restore'), 'wiki', $vars); } if (Current_User::allow('wiki', 'delete_page') && $this->getAllowEdit() && !$this->getVrCurrent()) { $vars['page_op'] = 'removeold'; $js_var['ADDRESS'] = PHPWS_Text::linkAddress('wiki', $vars, TRUE); $js_var['QUESTION'] = dgettext('wiki', 'Are you sure you want to remove this page revision?'); $js_var['LINK'] = dgettext('wiki', 'Remove'); $links[] = Layout::getJavascript('confirm', $js_var); } $template['ACTIONS'] = implode(' | ', $links); $template['VERSION'] = $this->getVrNumber(); $template['UPDATED'] = $this->getUpdated(); $template['EDITOR'] = $this->getEditor(); $template['COMMENT'] = $this->getComment() . ''; $template['DIFF'] = $this->getDiffOptions(); return $template; }
/** * DBPager row method for the floor edit pager. * * @return Array */ public function get_row_edit() { javascript('jquery'); $tpl = array(); $tpl['ID'] = $this->id; $tpl['ROOM_NUMBER'] = PHPWS_Text::secureLink($this->room_number, 'hms', array('action' => 'EditRoomView', 'room' => $this->id)); if (Current_User::allow('hms', 'room_structure') && $this->get_number_of_assignees() == 0) { $deleteRoomCmd = CommandFactory::getCommand('DeleteRoom'); $deleteRoomCmd->setRoomId($this->id); $deleteRoomCmd->setFloorId($this->floor_id); $confirm = array(); $confirm['QUESTION'] = 'Are you sure want to delete room ' . $this->room_number . '?'; $confirm['ADDRESS'] = $deleteRoomCmd->getURI(); $confirm['LINK'] = 'Delete'; $tpl['DELETE'] = Layout::getJavascript('confirm', $confirm); } $form = new PHPWS_Form($this->id); $form->addSelect('gender_type', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, COED => COED_DESC, AUTO => AUTO_DESC)); $form->setMatch('gender_type', $this->gender_type); $form->setExtra('gender_type', 'onChange="submit_form(this, true)"'); $form->addSelect('default_gender', array(FEMALE => FEMALE_DESC, MALE => MALE_DESC, AUTO => AUTO_DESC)); $form->setMatch('default_gender', $this->default_gender); $form->setExtra('default_gender', 'onChange="submit_form(this, true)"'); $form->addSelect('rlc_reserved', array('-1' => 'Select RLC') + RlcFactory::getRlcList($this->term)); $form->setMatch('rlc_reserved', $this->getReservedRlcId()); $form->setExtra('rlc_reserved', 'onChange="submit_form(this, true)"'); $form->addCheck('offline', 'yes'); $form->setMatch('offline', $this->offline == 1 ? 'yes' : 0); $form->setExtra('offline', 'onChange="submit_form(this, false)"'); $form->addCheck('reserved', 'yes'); $form->setMatch('reserved', $this->reserved == 1 ? 'yes' : 0); $form->setExtra('reserved', 'onChange="submit_form(this, false)"'); $form->addCheck('ra', 'yes'); $form->setMatch('ra', $this->ra == 1 ? 'yes' : 0); $form->setExtra('ra', 'onChange="submit_form(this, false)"'); $form->addCheck('private', 'yes'); $form->setMatch('private', $this->private == 1 ? 'yes' : 0); $form->setExtra('private', 'onChange="submit_form(this, false)"'); $form->addCheck('overflow', 'yes'); $form->setMatch('overflow', $this->overflow == 1 ? 'yes' : 0); $form->setExtra('overflow', 'onChange="submit_form(this, false)"'); $form->addCheck('ada', 'yes'); $form->setMatch('ada', $this->isAda() ? 'yes' : 0); $form->setExtra('ada', 'onChange="submit_form(this, false)"'); $form->addHidden('action', 'UpdateRoomField'); $form->addHidden('room', $this->id); $form->mergeTemplate($tpl); //test($form->getTemplate(),1); return $form->getTemplate(); }
public function getUserTpl() { // Don't let a deity change their deity status // Don't let non-deities change status if (Current_User::isDeity() && !Current_User::isUser($this->id)) { if ($this->isDeity()) { $dvars['QUESTION'] = dgettext('users', 'Are you sure you want to remove deity status?'); $dvars['ADDRESS'] = PHPWS_Text::linkAddress('users', array('action' => 'admin', 'command' => 'mortalize_user', 'user_id' => $this->id), 1); $dvars['LINK'] = sprintf('<i class="fa fa-cloud" title="%s"></i>', dgettext('users', 'Deity')); $links[] = javascript('confirm', $dvars); } else { $dvars['QUESTION'] = dgettext('users', 'Are you sure you want to deify this user?'); $dvars['ADDRESS'] = PHPWS_Text::linkAddress('users', array('action' => 'admin', 'command' => 'deify_user', 'user_id' => $this->id), 1); $dvars['LINK'] = sprintf('<i class="fa fa-male" title="%s"></i>', dgettext('users', 'Mortal')); $links[] = javascript('confirm', $dvars); } } $linkVar['action'] = 'admin'; $linkVar['user_id'] = $this->id; if ($this->isActive()) { if (!$this->deity) { $linkVar['command'] = 'deactivateUser'; $template['ACTIVE'] = PHPWS_Text::secureLink(dgettext('users', 'Yes'), 'users', $linkVar, null, dgettext('users', 'Deactivate this user')); } else { $template['ACTIVE'] = dgettext('users', 'Yes'); } } else { if (!$this->deity) { $linkVar['command'] = 'activateUser'; $template['ACTIVE'] = PHPWS_Text::secureLink(dgettext('users', 'No'), 'users', $linkVar, null, dgettext('users', 'Activate this user')); } else { $template['ACTIVE'] = dgettext('users', 'No'); } } $logged = $this->getLastLogged('%Y/%m/%d %H:%M'); if (empty($logged)) { $template['LAST_LOGGED'] = dgettext('users', 'Never'); } else { $template['LAST_LOGGED'] = $logged; } $template['EMAIL'] = $this->getEmail(true, true); $jsvar['QUESTION'] = sprintf(dgettext('users', 'Are you certain you want to delete the user "%s" permanently?'), $this->getUsername()); $link = new PHPWS_Link(null, 'users', array('action' => 'admin', 'command' => 'deleteUser', 'user_id' => $this->id), true); $link->setSalted(); $jsvar['ADDRESS'] = $link->getAddress(); $jsvar['LINK'] = '<i class="fa fa-trash-o" title="' . dgettext('users', 'Delete user') . '"></i>'; $linkVar['command'] = 'editUser'; $links[] = PHPWS_Text::secureLink('<i class="fa fa-edit"></i>', 'users', $linkVar); $linkVar['command'] = 'setUserPermissions'; $links[] = PHPWS_Text::secureLink('<i class="fa fa-key" title="' . dgettext('users', 'Permissions') . '"></i>', 'users', $linkVar); if (!$this->isDeity() && $this->id != Current_User::getId()) { $links[] = Layout::getJavascript('confirm', $jsvar); } $template['ACTIONS'] = implode(' ', $links); if ($this->deity && !Current_User::isDeity()) { unset($template['ACTIONS']); } return $template; }
public function getTplTags() { $this->loadMembers(); $id = $this->id; $linkVar['action'] = 'admin'; $linkVar['group_id'] = $id; $linkVar['command'] = 'edit_group'; $links[] = PHPWS_Text::secureLink('<i class="fa fa-edit"></i>', 'users', $linkVar, NULL, dgettext('users', 'Edit Group')); $linkVar['command'] = 'setGroupPermissions'; $links[] = PHPWS_Text::secureLink('<i class="fa fa-key" title="' . dgettext('users', 'Permissions') . '"></i>', 'users', $linkVar); $linkVar['command'] = 'manageMembers'; $links[] = PHPWS_Text::secureLink('<i class="fa fa-user" title="' . dgettext('users', 'Members') . '"></i>', 'users', $linkVar); $linkVar['command'] = 'remove_group'; $removelink['ADDRESS'] = PHPWS_Text::linkAddress('users', $linkVar, TRUE); $removelink['QUESTION'] = dgettext('users', 'Are you SURE you want to remove this group?'); $removelink['LINK'] = '<i class="fa fa-trash-o" title="' . dgettext('users', 'Remove') . '"></i>'; $links[] = Layout::getJavascript('confirm', $removelink); $template['ACTIONS'] = implode(' ', $links); $members = $this->getMembers(); if (isset($members)) { $template['MEMBERS'] = count($members); } else { $template['MEMBERS'] = 0; } return $template; }
public function getListAction() { $link['action'] = 'admin'; $link['blog_id'] = $this->id; if (Current_User::allow('blog', 'edit_blog') && Current_User::getId() == $this->author_id || Current_User::allow('blog', 'edit_blog', $this->id, 'entry')) { $link['command'] = 'edit'; $icon = Icon::show('edit', dgettext('blog', 'Edit blog entry')); $list[] = PHPWS_Text::secureLink($icon, 'blog', $link); } if (Current_User::allow('blog', 'delete_blog')) { $link['command'] = 'delete'; $confirm_vars['QUESTION'] = dgettext('blog', 'Are you sure you want to permanently delete this blog entry?'); $confirm_vars['ADDRESS'] = PHPWS_Text::linkAddress('blog', $link, true); $confirm_vars['LINK'] = '<i class="fa fa-trash-o" title="' . dgettext('blog', 'Delete blog entry') . '"></i>'; $list[] = Layout::getJavascript('confirm', $confirm_vars); } if (Current_User::isUnrestricted('blog')) { if ($this->sticky) { $link['command'] = 'unsticky'; $icon = Icon::show('flag', dgettext('blog', 'Remove from front page')); $list[] = PHPWS_Text::secureLink($icon, 'blog', $link); } else { $link['command'] = 'sticky'; $icon = Icon::show('flag-alt', dgettext('blog', 'Force to front page')); $list[] = PHPWS_Text::secureLink($icon, 'blog', $link); } } if (isset($list)) { $response = implode(' ', $list); } else { $response = dgettext('blog', 'No action'); } return $response; }