public function getOptions() { if (!$this->reported) { $opt[] = sprintf('<a style="cursor : pointer" class="message" id="%s">%s</a>', $this->from_user_id, \Icon::show('undo', 'Reply to contact')); $opt[] = sprintf('<a style="cursor:pointer" class="report" id="%s">%s</a>', $this->id, \Icon::show('warning', 'Report')); $opt[] = javascript('confirm', array('question' => 'Are you sure you want to delete this message?', 'address' => \PHPWS_Text::linkAddress('properties', array('rop' => 'delete_message', 'id' => $this->id)), 'link' => \Icon::show('delete'), 'title' => 'Delete message')); return implode('', $opt); } else { return null; } }
public function deleteLink($mode = 'link') { $vars['QUESTION'] = dgettext('filecabinet', 'Are you certain you want to delete this folder and all its contents?'); $vars['ADDRESS'] = PHPWS_Text::linkAddress('filecabinet', array('aop' => 'delete_folder', 'folder_id' => $this->id), true); $label = dgettext('filecabinet', 'Delete'); if ($mode == 'image') { $vars['LINK'] = Icon::show('delete', dgettext('filecabinet', 'Delete')); } else { $vars['LINK'] = $label; } return javascript('confirm', $vars); }
public function rowTags() { $vars['reason_id'] = $this->id; $vars['aop'] = 'edit_reason'; $links[] = PHPWS_Text::secureLink(Icon::show('edit'), 'checkin', $vars); $vars['aop'] = 'delete_reason'; $js['question'] = dgettext('confirm', 'Are you sure you want to delete this reason?.'); $js['address'] = PHPWS_Text::linkAddress('checkin', $vars, true); $js['link'] = Icon::show('delete'); $links[] = javascript('confirm', $js); $tpl['ACTION'] = implode('', $links); return $tpl; }
public function uploadNew($use_icon = true) { if ($use_icon) { $label = \Icon::show('image'); $content = <<<EOF <a style="cursor : pointer" id="{$this->pid}" class="photo-upload">{$label}</a> EOF; } else { $label = 'Add photo'; $content = <<<EOF <a style="cursor : pointer" id="{$this->pid}" class="btn btn-default photo-upload"><i class="fa fa-camera"></i> {$label}</a> EOF; } return $content; }
/** * @deprecated * @param type $icon * @return type */ public function deleteLink($icon = false) { $vars['mop'] = 'delete_multimedia'; $vars['multimedia_id'] = $this->id; $vars['folder_id'] = $this->folder_id; $js['QUESTION'] = dgettext('filecabinet', 'Are you sure you want to delete this multimedia file?'); $js['ADDRESS'] = PHPWS_Text::linkAddress('filecabinet', $vars, true); if ($icon) { $js['LINK'] = Icon::show('delete'); } else { $js['LINK'] = dgettext('filecabinet', 'Delete'); } return javascript('confirm', $js); }
public function viewImage($id, $view_folder = true) { Layout::addStyle('filecabinet'); PHPWS_Core::initModClass('filecabinet', 'Image.php'); $image = new PHPWS_Image($id); $folder = new Folder($image->folder_id); if (!$folder->allow()) { $content = dgettext('filecabinet', 'Sorry, the file you requested is off limits.'); Layout::add($content); return; } $tpl['TITLE'] = $image->title; if ($image->width > FC_MAX_IMAGE_POPUP_WIDTH || $image->height > FC_MAX_IMAGE_POPUP_HEIGHT) { if (FC_MAX_IMAGE_POPUP_WIDTH < FC_MAX_IMAGE_POPUP_HEIGHT) { $ratio = FC_MAX_IMAGE_POPUP_WIDTH / $image->width; $image->width = FC_MAX_IMAGE_POPUP_WIDTH; $image->height = $image->height * $ratio; } else { $ratio = FC_MAX_IMAGE_POPUP_HEIGHT / $image->height; $image->height = FC_MAX_IMAGE_POPUP_HEIGHT; $image->width = $image->width * $ratio; } $tpl['IMAGE'] = sprintf('<a href="%s">%s</a>', $image->getPath(), $image->getTag()); } else { $tpl['IMAGE'] = $image->getTag(); } $tpl['DESCRIPTION'] = $image->getDescription(); $tpl['CLOSE'] = javascript('close_window'); if ($view_folder && $folder->public_folder) { $db = new PHPWS_DB('images'); $db->setLimit(1); $db->addWhere('folder_id', $image->folder_id); $db->addWhere('title', $image->title, '>'); $db->addOrder('title'); $next_img = $db->getObjects('PHPWS_Image'); if (!empty($next_img)) { $next_link = Icon::show('next', dgettext('filecabinet', 'Next image')); $tpl['NEXT'] = sprintf('<a id="next-link" href="%s%s">%s</a>', PHPWS_Core::getHomeHttp(), $next_img[0]->popupAddress(), $next_link); } $db->resetWhere(); $db->resetOrder(); $db->addWhere('folder_id', $image->folder_id); $db->addWhere('title', $image->title, '<'); $db->addOrder('title desc'); $prev_img = $db->getObjects('PHPWS_Image'); if (!empty($prev_img)) { $prev_link = Icon::show('previous', dgettext('filecabinet', 'Previous image')); $tpl['PREV'] = sprintf('<a id="prev-link" href="%s%s">%s</a>', PHPWS_Core::getHomeHttp(), $prev_img[0]->popupAddress(), $prev_link); } } $content = PHPWS_Template::process($tpl, 'filecabinet', 'image_view.tpl'); Layout::nakedDisplay($content); }
public function getTpl() { $vars['block_id'] = $this->getId(); if (Current_User::allow('block', 'edit_block', $this->id)) { $vars['action'] = 'edit'; $links[] = PHPWS_Text::secureLink(Icon::show('edit', dgettext('block', 'Edit')), 'block', $vars); if ($this->allPinned()) { $vars['action'] = 'remove'; $links[] = PHPWS_Text::secureLink("<i class='fa fa-flag' title='" . dgettext('block', 'Remove block from all pages') . "'></i>", 'block', $vars); } else { $vars['action'] = 'pin_all'; $links[] = PHPWS_Text::secureLink("<i class='fa fa-flag-o' title='" . dgettext('block', 'Display block on all pages') . "'></i>", 'block', $vars); } if (Current_User::isUnrestricted('block')) { $links[] = Current_User::popupPermission($this->key_id, null, 'icon'); } } if (Current_User::allow('block', 'delete_block')) { $vars['action'] = 'delete'; $confirm_vars['QUESTION'] = dgettext('block', 'Are you sure you want to permanently delete this block?'); $confirm_vars['ADDRESS'] = PHPWS_Text::linkAddress('block', $vars, TRUE); $confirm_vars['LINK'] = '<i class="fa fa-trash-o" title="' . dgettext('block', 'Delete') . '"></i>'; $links[] = javascript('confirm', $confirm_vars); } if (!empty($links)) { $template['ACTION'] = implode('', $links); } else { $template['ACTION'] = ' '; } if (empty($this->title)) { $template['TITLE'] = '<em>' . dgettext('block', 'Untitled') . '</em>'; } if (empty($this->content)) { $template['CONTENT'] = '<em>' . dgettext('block', 'Empty') . '</em>'; } else { $template['CONTENT'] = $this->summarize(); } return $template; }
public static function userForm(PHPWS_User $user, $message = NULL) { javascript('jquery'); javascriptMod('users', 'generate'); $form = new PHPWS_Form('edit-user'); if ($user->getId() > 0) { $form->addHidden('user_id', $user->getId()); $form->addSubmit('go', dgettext('users', 'Update User')); } else { $form->addSubmit('go', dgettext('users', 'Add User')); } $form->addHidden('action', 'admin'); $form->addHidden('command', 'postUser'); $form->addHidden('module', 'users'); $form->addCheckbox('notify_user', 1); $form->setLabel('notify_user', dgettext('user', 'Notify user of account creation')); if (Current_User::allow('users', 'settings')) { $db = new PHPWS_DB('users_auth_scripts'); $db->setIndexBy('id'); $db->addColumn('id'); $db->addColumn('display_name'); $result = $db->select('col'); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); } else { if (!isset($result[$user->authorize])) { $message['AUTHORIZE'] = dgettext('users', 'Warning: this user\'s authorization script is broken. Choose another and update.'); } $form->addSelect('authorize', $result); $form->setMatch('authorize', $user->authorize); $form->setLabel('authorize', dgettext('users', 'Authorization')); } } if (!$user->id || $user->canChangePassword()) { $form->addText('username', $user->getUsername()); $form->setRequired('username'); $form->setLabel('username', dgettext('users', 'Username')); $form->addPassword('password1'); $form->addPassword('password2'); $form->setLabel('password1', dgettext('users', 'Password')); $form->addButton('create_pw', dgettext('users', 'Generate password')); } else { $form->addTplTag('USERNAME', $user->getUsername()); $form->addTplTag('USERNAME_LABEL', '<strong>' . dgettext('users', 'Username') . '</strong>'); } $form->addText('display_name', $user->display_name); $form->addText('email', $user->getEmail()); $form->setSize('email', 30); $form->setRequired('email'); $form->setLabel('email', dgettext('users', 'Email Address')); $form->setLabel('display_name', dgettext('users', 'Display name')); if (isset($tpl)) { $form->mergeTemplate($tpl); } $template = $form->getTemplate(); $vars['action'] = 'admin'; $vars['user_id'] = $user->id; if ($user->id) { $vars['command'] = 'setUserPermissions'; $links[] = PHPWS_Text::secureLink(\Icon::show('permission') . ' ' . dgettext('users', 'Permissions'), 'users', $vars, null, dgettext('users', 'Permissions'), 'btn btn-default'); } if (isset($links)) { $template['LINKS'] = implode(' | ', $links); } if (isset($message)) { foreach ($message as $tag => $error) { $template[strtoupper($tag) . '_ERROR'] = $error; } } if (!$user->id) { $template['JOIN_GROUPS'] = self::getJoinGroups(); } else { $group_ids = $user->getGroups(); if ($group_ids) { $db = Database::newDB(); $t1 = $db->addTable('users_groups'); $f1 = $t1->addField('name'); $c1 = $t1->getFieldConditional('id', $group_ids, 'in'); $c2 = $t1->getFieldConditional('user_id', 0); $db->stackConditionals($c1, $c2); while ($group = $db->selectColumn()) { $template['members'][] = array('NAME' => $group); } } if (!isset($template['members'])) { $template['EMPTY_GROUP'] = dgettext('user', 'User not a member of any group'); } } return PHPWS_Template::process($template, 'users', 'forms/userForm.tpl'); }
/** * @deprecated * @param type $icon * @return type */ public function editLink($icon = false) { $vars['document_id'] = $this->id; $vars['folder_id'] = $this->folder_id; $vars['dop'] = 'upload_document_form'; $link = new PHPWS_Link(null, 'filecabinet', $vars, true); $link->setSalted(1); $js['address'] = $link->getAddress(); $js['width'] = 550; $js['height'] = 500; if ($icon) { $js['label'] = Icon::show('edit', dgettext('filecabinet', 'Edit document')); } else { $js['label'] = dgettext('filecabinet', 'Edit'); } return javascript('open_window', $js); }
public function row_tags($contact_command = false) { //$tpl['NAME'] = $this->viewLink($this->name); $name = strlen($this->name) > 30 ? substr($this->name, 0, 30) . '...' : $this->name; $tpl['NAME'] = $this->viewLink($name); if ($contact_command) { $cmd = 'cop'; $cmd_array['k'] = $_SESSION['Contact_User']->getKey(); } else { $cmd = 'aop'; $cmd_array['authkey'] = \Current_User::getAuthKey(); } $cmd_array['pid'] = $this->id; if ($this->active) { $cmd_array[$cmd] = 'deactivate_property'; $admin[] = \PHPWS_Text::moduleLink(\Icon::show('active', 'Click to deactivate'), 'properties', $cmd_array); } else { $cmd_array[$cmd] = 'activate_property'; $admin[] = \PHPWS_Text::moduleLink(\Icon::show('inactive', 'Click to activate'), 'properties', $cmd_array); } $cmd_array[$cmd] = 'edit_property'; $admin[] = \PHPWS_Text::secureLink(\Icon::show('edit'), 'properties', $cmd_array); $cmd_array[$cmd] = 'update'; if ($this->active) { $tpl['TIMEOUT'] = \PHPWS_Text::moduleLink($this->getTimeout(), 'properties', $cmd_array); } else { $tpl['TIMEOUT'] = 'N/A'; } $photo = new Photo(); $photo->setPropertyId($this->id); $admin[] = $photo->uploadNew(); $js['LINK'] = \Icon::show('delete'); $js['QUESTION'] = 'Are you sure you want to delete this property?'; if ($contact_command) { $js['ADDRESS'] = 'index.php?module=properties&cop=delete_property&pid=' . $this->id . '&k=' . $_SESSION['Contact_User']->getKey(); } else { $js['ADDRESS'] = 'index.php?module=properties&aop=delete_property&pid=' . $this->id . '&authkey=' . \Current_User::getAuthKey(); } $admin[] = javascript('confirm', $js); $tpl['ACTION'] = implode('', $admin); return $tpl; }
public function showPeeps() { $sheet = new Signup_Sheet($this->sheet_id); $total_slots = $sheet->totalSlotsFilled(); $all_slots = $sheet->getAllSlots(); foreach ($all_slots as $slot) { if ($slot->id == $this->id) { continue; } elseif (!isset($total_slots[$slot->id]) || $slot->openings != $total_slots[$slot->id]) { $options[$slot->id] = $slot->title; } } $ex1 = sprintf('<abbr title="%s"><strong>1:</strong></abbr> ', $sheet->extra1); $ex2 = sprintf('<abbr title="%s"><strong>2:</strong></abbr> ', $sheet->extra2); $ex3 = sprintf('<abbr title="%s"><strong>3:</strong></abbr> ', $sheet->extra3); if ($this->_peeps) { $jsconf['QUESTION'] = dgettext('signup', 'Are you sure you want to delete this person from their signup slot?'); $jsconf['LINK'] = Icon::show('delete'); $jspop['label'] = Icon::show('edit'); foreach ($this->_peeps as $peep) { $links = array(); $subtpl = array(); $subtpl['FIRST_NAME'] = $peep->first_name; $subtpl['LAST_NAME'] = $peep->last_name; $subtpl['EMAIL'] = $peep->getEmail(); $subtpl['PHONE'] = $peep->getPhone(); if (!empty($sheet->extra1)) { $subtpl['EXTRA1'] = $ex1 . $peep->getExtra1(); } if (!empty($sheet->extra2)) { $subtpl['EXTRA2'] = $ex2 . $peep->getExtra2(); } if (!empty($sheet->extra3)) { $subtpl['EXTRA3'] = $ex3 . $peep->getExtra3(); } $vars['peep_id'] = $peep->id; $vars['aop'] = 'edit_slot_peep'; $jspop['address'] = PHPWS_Text::linkAddress('signup', $vars, true); $jspop['width'] = 300; $jspop['height'] = 600; $links[] = javascript('open_window', $jspop); $vars['aop'] = 'delete_slot_peep'; $jsconf['ADDRESS'] = PHPWS_Text::linkAddress('signup', $vars, true); $links[] = javascript('confirm', $jsconf); $subtpl['ACTION'] = implode('', $links); if (!empty($options)) { $form = new PHPWS_Form(); $form->addHidden('module', 'signup'); $form->addHidden('aop', 'move_peep'); $form->addHidden('peep_id', $peep->id); $form->addSelect('mv_slot', $options); $form->addSubmit(dgettext('signup', 'Go')); $tmptpl = $form->getTemplate(); $subtpl['MOVE'] = $tmptpl['START_FORM'] . $tmptpl['MV_SLOT'] . $tmptpl['SUBMIT'] . $tmptpl['END_FORM']; } else { $subtpl['MOVE'] = dgettext('signup', 'Other slots full'); } $tpl['peep-row'][] = $subtpl; } $tpl['NAME_LABEL'] = dgettext('signup', 'Name'); $tpl['EMAIL_LABEL'] = dgettext('signup', 'Email'); $tpl['PHONE_LABEL'] = dgettext('signup', 'Phone'); $tpl['ACTION_LABEL'] = dgettext('signup', 'Action'); $tpl['ORGANIZATION_LABEL'] = dgettext('signup', 'Organization'); $tpl['MOVE_LABEL'] = dgettext('signup', 'Move'); $tpl['EXTRA1_LABEL'] = 'Extra info'; return PHPWS_Template::process($tpl, 'signup', 'peeps.tpl'); } }
public function row_tags() { if ($this->filter_type == 0x0) { // if no filters are selected $tpl['FILTER_INFO'] = dgettext('checkin', 'None'); } else { $filterInfo = array(); if ($this->filter_type & LAST_NAME_BITMASK) { $filterInfo[] = 'Last Name'; } if ($this->filter_type & REASON_BITMASK) { $filterInfo[] = 'Reason'; } if ($this->filter_type & GENDER_BITMASK) { $filterInfo[] = 'Gender'; } if ($this->filter_type & BIRTHDATE_BITMASK) { $filterInfo[] = 'Birthdate'; } $tpl['FILTER_INFO'] = implode('<br>', $filterInfo); } $vars['staff_id'] = $this->id; if ($this->active) { $links[] = \PHPWS_Text::secureLink(\Icon::show('active', 'Click to deactivate'), 'checkin', array('aop' => 'deactivate_staff', 'id' => $this->id)); } else { $links[] = \PHPWS_Text::secureLink(\Icon::show('inactive', 'Click to activate'), 'checkin', array('aop' => 'activate_staff', 'id' => $this->id)); } $vars['aop'] = 'edit_staff'; $links[] = PHPWS_Text::secureLink(Icon::show('edit'), 'checkin', $vars); $vars['aop'] = 'move_up'; $links[] = PHPWS_Text::secureLink(Icon::show('up'), 'checkin', $vars); $vars['aop'] = 'move_down'; $links[] = PHPWS_Text::secureLink(Icon::show('down'), 'checkin', $vars); $tpl['VIEW_ORDER'] = $this->view_order; $tpl['ACTION'] = implode('', $links); return $tpl; }
/** * Returns a list of items based on the table currently set in this manager * * @param string $listName The name of the list wanting to be returned * @param string $title The title of the list * @param boolean $makeForm Flag whether or not to make a form out of the list * @access public */ function getList($listName, $title = NULL, $makeForm = TRUE, $overRideOp = NULL) { $this->listName = $listName; if (!isset($this->_table) && !isset($this->_request)) { $message = _('Manager was not fully initialized to get a list.'); $error = new PHPWS_Error('core', 'PHPWS_Manager::getList()', $message, 'exit', 1); $error->message(NULL); } $theme = Layout::getCurrentTheme(); $themeModuleRowTpl = "themes/{$theme}/templates/" . $this->_module . '/' . $this->_templates[$this->listName] . '/row.tpl'; $moduleRowTpl = PHPWS_SOURCE_DIR . 'mod/' . $this->_module . '/templates/' . $this->_templates[$this->listName] . '/row.tpl'; $themeCoreRowTpl = 'themes/' . $theme . '/templates/core/defaultRow.tpl'; $coreRowTpl = PHPWS_SOURCE_DIR . 'templates/defaultRow.tpl'; $themeModuleListTpl = "themes/{$theme}/templates/" . $this->_module . '/' . $this->_templates[$this->listName] . '/list.tpl'; $moduleListTpl = PHPWS_SOURCE_DIR . 'mod/' . $this->_module . '/templates/' . $this->_templates[$this->listName] . '/list.tpl'; $themeCoreListTpl = "themes/{$theme}/templates/core/defaultList.tpl"; $coreListTpl = PHPWS_SOURCE_DIR . 'templates/defaultList.tpl'; if (file_exists($themeModuleRowTpl)) { $rowTpl = $themeModuleRowTpl; } else { if (file_exists($moduleRowTpl)) { $rowTpl = $moduleRowTpl; } else { if (file_exists($themeCoreRowTpl)) { $rowTpl = $themeCoreRowTpl; } else { $rowTpl = $coreRowTpl; } } } if (file_exists($themeModuleListTpl)) { $listTpl = $themeModuleListTpl; } else { if (file_exists($moduleListTpl)) { $listTpl = $moduleListTpl; } else { if (file_exists($themeCoreListTpl)) { $listTpl = $themeCoreListTpl; } else { $listTpl = $coreListTpl; } } } if (isset($_REQUEST['PHPWS_MAN_LIST']) && $this->listName == $_REQUEST['PHPWS_MAN_LIST']) { $this->catchOrder(); } if (isset($overRideOp)) { $op = $overRideOp; } else { if (isset($this->_listPaging[$this->listName]['op'])) { $op = $this->_listPaging[$this->listName]['op']; } } if (isset($this->_listPaging[$this->listName]) && is_array($this->_listPaging[$this->listName])) { if (!isset($this->_pagers[$this->listName])) { $this->_pagers[$this->listName] = new PHPWS_Pager(); $this->_pagers[$this->listName]->setLinkBack('./index.php?module=' . $this->_module . '&' . $op . '&PHPWS_MAN_PAGE=' . $this->listName); $this->_pagers[$this->listName]->setLimits($this->_listPaging[$this->listName]['limits']); $this->_pagers[$this->listName]->makeArray(TRUE); if ($this->_anchor) { $this->_pagers[$this->listName]->setAnchor('#' . $this->listName); } $this->_pagers[$this->listName]->limit = $this->_listPaging[$this->listName]['limit']; } $this->_pagers[$this->listName]->setData($this->_getIds()); if (isset($_REQUEST['PHPWS_MAN_PAGE']) && $this->listName == $_REQUEST['PHPWS_MAN_PAGE']) { $this->_pagers[$this->listName]->pageData(); } else { $this->_pagers[$this->listName]->pageData(FALSE); } if (isset($this->_class)) { $items = $this->getItems($this->_pagers[$this->listName]->getData(), FALSE, TRUE); } else { $items = $this->getItems($this->_pagers[$this->listName]->getData()); } $totalItems = count($items); // $totalItems = $this->_pagers[$this->listName]->getNumRows(); } else { if (isset($this->_class)) { $items = $this->getItems(NULL, FALSE, TRUE); } else { $items = $this->getItems(); } $totalItems = sizeof($items); } /* Begin building main list tags array for processTemplate() */ $listTags = array(); if (isset($this->_listExtraLabels) && is_array($this->_listExtraLabels)) { $listTags = $this->_listExtraLabels; } $listTags['TITLE'] = $title; $listTags['ANCHOR'] = '<a id="' . $this->listName . '" name="' . $this->listName . '"></a>'; if ($makeForm) { $listTags['SELECT_LABEL'] = ' '; } $columns = 0; foreach ($this->_listColumns[$this->listName] as $listColumn => $listLabel) { $column = strtoupper($listColumn); $key0 = $column . '_LABEL'; $key1 = $column . '_ORDER_LINK'; $listTags[$key0] = NULL; $listTags[$key1] = NULL; $listTags[$key0] = $listLabel; if (isset($overRideOp)) { $request = $overRideOp; } else { if (isset($this->_listPaging[$this->listName]['op'])) { $request = $this->_listPaging[$this->listName]['op']; } else { $request = $this->_request . '=list'; } } if ($totalItems > 0) { $anchor = ''; if ($this->_anchor) { $anchor = '#' . $this->listName; } if (isset($this->_overrideOrder[$this->listName][$listColumn][0])) { $overRide = $this->_overrideOrder[$this->listName][$listColumn][0]; } else { $overRide = 'default'; } if (isset($this->_listPaging[$this->listName])) { switch ($overRide) { case 0: $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&' . $request . '&PHPWS_MAN_LIST=' . $this->listName . '&PHPWS_MAN_COLUMN=' . $listColumn . '&PHPWS_MAN_ORDER=1&' . 'PHPWS_MAN_PAGE=' . $this->listName . '&' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">'; $listTags[$key1] .= Icon::show('sort') . '</a>'; break; case 1: $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&' . $request . '&PHPWS_MAN_LIST=' . $this->listName . '&PHPWS_MAN_COLUMN=' . $listColumn . '&PHPWS_MAN_ORDER=2&' . 'PHPWS_MAN_PAGE=' . $this->listName . '&' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">'; $listTags[$key1] .= Icon::show('sort-up') . '</a>'; break; case 2: $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&' . $request . '&PHPWS_MAN_LIST=' . $this->listName . '&PHPWS_MAN_COLUMN=' . $listColumn . '&PHPWS_MAN_ORDER=0&' . 'PHPWS_MAN_PAGE=' . $this->listName . '&' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">'; $listTags[$key1] .= Icon::show('sort-down') . '</a>'; break; default: $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&' . $request . '&PHPWS_MAN_LIST=' . $this->listName . '&PHPWS_MAN_COLUMN=' . $listColumn . '&PHPWS_MAN_ORDER=1&' . 'PHPWS_MAN_PAGE=' . $this->listName . '&' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">'; $listTags[$key1] .= Icon::show('sort') . '</a>'; } } } $columns++; } /* Build each item's row */ $listTags['LIST_ITEMS'] = NULL; if ($totalItems > 0) { $tog = 1; foreach ($items as $item) { $object = NULL; if (isset($this->_class)) { $object = new $this->_class($item); $className = get_class($object); $classMethods = get_class_methods($className); @array_walk($classMethods, 'manager_lower_methods'); $objectVars = get_object_vars($object); if (is_array($objectVars)) { $item = $objectVars; foreach ($item as $key => $value) { if ($key[0] == '_') { $key = substr($key, 1, strlen($key)); $item[$key] = $value; } } } } if ($tog % 2) { $row_class = ' class="bgcolor1"'; } else { $row_class = null; } $tog++; /* Build row tags array for processTemplate() */ $rowTags = array(); if (isset($this->_listExtraLabels) && is_array($this->_listExtraLabels)) { $rowTags = $this->_listExtraLabels; } $rowTags['ROW_CLASS'] = $row_class; if ($makeForm) { $ele = new Form_CheckBox('PHPWS_MAN_ITEMS[]', $item['id']); $rowTags['SELECT'] = $ele->get(); } foreach ($this->_listColumns[$this->listName] as $listColumn => $listLabel) { $column = strtoupper($listColumn); if ($listColumn == 'created') { /* Set created date using phpwebsite's default date and time formats */ $rowTags['CREATED'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $item['created']); } else { if ($listColumn == 'updated') { /* Set updated date using phpwebsite's default date and time formats */ $rowTags['UPDATED'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $item['updated']); } else { if ($listColumn == 'hidden') { /* Setting message depending if this item is hidden or not */ if (isset($this->_listValues['hidden'])) { $rowTags['HIDDEN'] = $this->_listValues['hidden'][$item['hidden']]; } else { if ($item['hidden'] == 1) { $rowTags['HIDDEN'] = _('Hidden'); } else { $rowTags['HIDDEN'] = _('Visible'); } } } else { if ($listColumn == 'approved') { /* Setting message depending if this item is approved or not */ if (isset($this->_listValues['hidden'])) { $rowTags['APPROVED'] = $this->_listValues['approved'][$item['approved']]; } else { if ($item['approved'] == 1) { $rowTags['APPROVED'] = _('Approved'); } else { $rowTags['APPROVED'] = _('Unapproved'); } } } else { if ($listColumn == 'groups') { $groups = unserialize($item['groups']); if (is_array($groups) && sizeof($groups) > 0) { /* Set flag to check whether to add a comma or not */ $flag = FALSE; /* Create a string of group names the current item belongs to */ foreach ($groups as $group) { if ($flag) { $rowTags['GROUPS'] .= ', '; } $rowTags['GROUPS'] .= $group; $flag = TRUE; } } else { $rowTags['GROUPS'] = _('All'); } } else { $method = 'get' . $listColumn; if (is_object($object) && in_array($method, $classMethods)) { $rowTags[$column] = $object->{$method}(); } else { $rowTags[$column] = $item[$listColumn]; } } } } } } } /* Process this item and concatenate onto the current list of items */ $listTags['LIST_ITEMS'] .= PHPWS_Template::processTemplate($rowTags, 'core', $rowTpl, FALSE); } if (isset($this->_listPaging[$this->listName]) && is_array($this->_listPaging[$this->listName]) && sizeof($this->_listPaging[$this->listName]) > 0) { $listTags['NAV_BACKWARD'] = $this->_pagers[$this->listName]->getBackLink($this->_listPaging[$this->listName]['back']); $listTags['NAV_FORWARD'] = $this->_pagers[$this->listName]->getForwardLink($this->_listPaging[$this->listName]['forward']); if (isset($this->_listPaging[$this->listName]['section'])) { $listTags['NAV_SECTIONS'] = $this->_pagers[$this->listName]->getSectionLinks(); } $listTags['NAV_LIMITS'] = $this->_pagers[$this->listName]->getLimitLinks(); $listTags['NAV_INFO'] = $this->_pagers[$this->listName]->getSectionInfo(); } $actions = array(); if (isset($this->_listActions[$this->listName]) && is_array($this->_listActions[$this->listName])) { foreach ($this->_listActions[$this->listName] as $actionString => $actionLabel) { if (isset($this->_listPermissions[$this->listName][$actionString])) { $permission = $this->_listPermissions[$this->listName][$actionString]; } if (isset($permission)) { if (Current_User::allow($this->_module, $permission)) { $actions[$actionString] = $actionLabel; } } else { $actions[$actionString] = $actionLabel; } } } if ($makeForm) { /* Create action select and Go button */ $ele = new Form_Select($this->_request, $actions); $listTags['ACTION_SELECT'] = $ele->get(); $listTags['ACTION_BUTTON'] = sprintf('<input type="submit" value="%s" />', _('Go')); $listTags['TOGGLE_ALL'] = javascript('check_all', array('FORM_NAME' => 'PHPWS_MAN_LIST_' . $this->listName)); /* Add hidden variable to designate the current module */ $ele = new Form_Hidden('module', $this->_module); $elements[0] = $ele->get(); $elements[0] .= PHPWS_Template::processTemplate($listTags, 'core', $listTpl, FALSE); /* Create final form and dump it into a content variable to be returned */ $content = sprintf('<form name="%s" action="index.php" method="post">%s</form>', 'PHPWS_MAN_LIST_' . $this->listName, implode("\n", $elements)); } else { $content = PHPWS_Template::processTemplate($listTags, 'core', $listTpl, FALSE); } } else { $listTags['LIST_ITEMS'] = '<tr><td colspan="' . $columns . '">' . _('No items for the current list.') . '</td></tr>'; $content = PHPWS_Template::processTemplate($listTags, 'core', $listTpl, FALSE); } /* reinitialize sort and order before next list */ $this->setSort(NULL); $this->setOrder(NULL); $this->_class = NULL; return $content; }
public function rowTags() { if ($this->checkPermissions()) { $links[] = '<i class="fa fa-plus add-event" style="cursor:pointer" data-schedule-id="' . $this->id . '" data-date="' . time() . '"></i>'; //$links[] = $this->addEventLink(null, true, true); $links[] = $this->uploadEventsLink(null, true); $links[] = $this->downloadEventsLink(null, true); $links[] = '<i class="fa fa-edit" id="edit-schedule" data-schedule-id="' . $this->id . '" style="cursor:pointer" title="' . dgettext('calendar', 'Edit schedule') . '"></i>'; } if (Current_User::allow('calendar', 'delete_schedule') && Current_User::isUnrestricted('calendar')) { $js['QUESTION'] = dgettext('calendar', 'Are you sure you want to delete this schedule?'); $js['ADDRESS'] = sprintf('index.php?module=calendar&aop=delete_schedule&sch_id=%s&authkey=%s', $this->id, Current_User::getAuthKey()); $js['LINK'] = Icon::show('delete'); $links[] = javascript('confirm', $js); } if ($this->public && Current_User::isUnrestricted('calendar')) { $public_schedule = PHPWS_Settings::get('calendar', 'public_schedule'); if ($public_schedule != $this->id) { $link_vars['aop'] = 'make_default_public'; $link_vars['sch_id'] = $this->id; $links[] = PHPWS_Text::secureLink(dgettext('calendar', 'Make default public'), 'calendar', $link_vars); } else { $links[] = dgettext('calendar', 'Default public'); } } if (!empty($links)) { $tags['ADMIN'] = implode(' ', $links); } else { $tags['ADMIN'] = dgettext('calendar', 'None'); } $tags['TITLE'] = $this->getViewLink(); if ($this->public) { $tags['AVAILABILITY'] = dgettext('calendar', 'Public'); } else { $tags['AVAILABILITY'] = dgettext('calendar', 'Private'); } return $tags; }
function downloadLink($startdate, $enddate) { if ($this->calendar->schedule->allowICalDownload()) { $dl['uop'] = 'ical_dl'; $dl['sch_id'] = $this->calendar->schedule->id; $dl['sdate'] = $startdate; $dl['edate'] = $enddate; $icon = Icon::show('download'); $download = new PHPWS_Link($icon, 'calendar', $dl); $download->setNoFollow(); return $download->get(); } else { return null; } }
public function addPageLink($label = null, $icon = false) { if (empty($label)) { $label = dgettext('pagesmith', 'Add page'); } if ($icon) { $label = Icon::show('add', $label); } $vars['pid'] = $this->id; $vars['aop'] = 'menu'; $vars['tab'] = 'new'; return PHPWS_Text::secureLink($label, 'pagesmith', $vars); }
public function row_tags() { $tpl['LAST_NAME'] = sprintf('<a href="mailto:%s">%s, %s <i class="fa fa-envelope-o"></i></a>', $this->email_address, $this->last_name, $this->first_name); $tpl['PHONE'] = $this->getPhone(); $tpl['COMPANY_NAME'] = $this->getCompanyUrl(); if ($this->active) { $admin[] = \PHPWS_Text::secureLink(\Icon::show('active', 'Click to deactivate'), 'properties', array('aop' => 'deactivate_contact', 'cid' => $this->id)); } else { $admin[] = \PHPWS_Text::secureLink(\Icon::show('inactive', 'Click to activate'), 'properties', array('aop' => 'activate_contact', 'cid' => $this->id)); } $admin[] = \PHPWS_Text::secureLink(\Icon::show('add'), 'properties', array('aop' => 'edit_property', 'cid' => $this->id)); $admin[] = \PHPWS_Text::secureLink(\Icon::show('edit'), 'properties', array('aop' => 'edit_contact', 'cid' => $this->id)); $js['LINK'] = \Icon::show('delete'); $js['QUESTION'] = 'Are you sure you want to delete this contact and all their properties?'; $js['ADDRESS'] = 'index.php?module=properties&aop=delete_contact&cid=' . $this->id . '&authkey=' . \Current_User::getAuthKey(); $admin[] = javascript('confirm', $js); $admin[] = \PHPWS_Text::secureLink(\Icon::show('home', 'Show properties'), 'properties', array('aop' => 'show_properties', 'cid' => $this->id)); if ($this->last_log) { $tpl['LAST_LOG'] = strftime('%x', $this->last_log); } else { $tpl['LAST_LOG'] = 'Never'; } $tpl['ACTION'] = implode('', $admin); return $tpl; }
public function rowTag() { $vars['sheet_id'] = $this->id; if (Current_User::allow('signup', 'edit_sheet', $this->id, 'sheet')) { if (Current_User::isUnrestricted('signup')) { $vars['aop'] = 'edit_sheet'; $links[] = PHPWS_Text::secureLink(\Icon::show('edit', dgettext('signup', 'Edit')), 'signup', $vars); } $vars['aop'] = 'edit_slots'; $links[] = PHPWS_Text::secureLink(\Icon::show('th-list', dgettext('signup', 'Slots')), 'signup', $vars); if (Current_User::isUnrestricted('signup')) { $links[] = Current_User::popupPermission($this->key_id, null, 'icon'); } } $vars['aop'] = 'report'; $links[] = PHPWS_Text::secureLink(\Icon::show('file-text', dgettext('signup', 'Report')), 'signup', $vars); if (Current_User::isUnrestricted('signup')) { $vars['aop'] = 'delete_sheet'; $js['ADDRESS'] = PHPWS_Text::linkAddress('signup', $vars, true); $js['QUESTION'] = dgettext('signup', 'Are you sure you want to delete this sheet?\\nAll slots and signup information will be permanently removed.'); $js['LINK'] = \Icon::show('delete'); $links[] = javascript('confirm', $js); } $tpl['START_TIME'] = strftime("%D %R", $this->start_time); // MM/DD/YY hh:mm 24-hour time format $tpl['END_TIME'] = strftime("%D %R", $this->end_time); // MM/DD/YY hh:mm 24-hour time format $tpl['TITLE'] = $this->viewLink(); $tpl['ACTION'] = implode(' ', $links); return $tpl; }
/** * Returns an associative array for the branch list page */ public function getTpl() { $tpl['URL'] = $this->getUrl(); $links[] = PHPWS_Text::secureLink(Icon::show('edit'), 'branch', array('command' => 'edit_branch', 'branch_id' => $this->id)); $js['question'] = dgettext('branch', 'Removing this branch will make it inaccessible.\\nThe database and files will remain behind.\\nIf you are sure you want to remove the branch, type the branch name:'); $js['address'] = sprintf('index.php?module=branch&command=remove_branch&branch_id=%s&authkey=%s', $this->id, Current_User::getAuthKey()); $js['value_name'] = 'branch_name'; $js['link'] = Icon::show('delete'); $links[] = javascript('prompt', $js); $tpl['DIRECTORY'] = sprintf('<abbr title="%s">%s</abbr>', $this->directory, PHPWS_Text::shortenUrl($this->directory)); $tpl['ACTION'] = implode(' ', $links); return $tpl; }
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; }