Exemplo n.º 1
0
 public static function setTitle($module, $link, $add_authkey = false)
 {
     if ($add_authkey) {
         $link = sprintf('%s&authkey=%s', $link, Current_User::getAuthKey());
     }
     $GLOBALS['MiniAdmin'][$module]['title_link'] = $link;
 }
Exemplo n.º 2
0
 public function pagerTags()
 {
     $vars['command'] = 'reset_feed';
     $vars['feed_id'] = $this->id;
     $links[] = PHPWS_Text::secureLink('<i class="fa fa-refresh" title="' . dgettext('rss', 'Reset') . '"></i>', 'rss', $vars);
     $links[] = '<i data-id="' . $this->id . '" class="edit-feed pointer fa fa-edit" title="' . dgettext('rss', 'Edit the feed') . '"></i>';
     $js['QUESTION'] = dgettext('rss', 'Are you sure you want to delete this RSS feed?');
     $js['ADDRESS'] = sprintf('index.php?module=rss&command=delete_feed&feed_id=%s&authkey=%s', $this->id, Current_User::getAuthKey());
     $js['LINK'] = '<i class="fa fa-trash-o" title="' . dgettext('rss', 'Delete feed') . '"></i>';
     $links[] = javascript('confirm', $js);
     $tpl['ACTION'] = implode(' ', $links);
     if ($this->display) {
         $vars['command'] = 'turn_off_display';
         $tpl['DISPLAY'] = PHPWS_Text::secureLink(dgettext('rss', 'Yes'), 'rss', $vars);
     } else {
         $vars['command'] = 'turn_on_display';
         $tpl['DISPLAY'] = PHPWS_Text::secureLink(dgettext('rss', 'No'), 'rss', $vars);
     }
     $hours = floor($this->refresh_time / 3600);
     $remaining = $this->refresh_time - $hours * 3600;
     $minutes = floor($remaining / 60);
     $seconds = $remaining - $minutes * 60;
     $time = NULL;
     if ($seconds) {
         $time = sprintf(dgettext('rss', '%d seconds'), $seconds);
     }
     if ($minutes) {
         if (isset($time)) {
             $time = sprintf(dgettext('rss', '%d minutes, '), $minutes) . $time;
         } else {
             $time = sprintf(dgettext('rss', '%d minutes'), $minutes) . $time;
         }
     }
     if ($hours) {
         if (isset($time)) {
             $time = sprintf(dgettext('rss', '%d hours, '), $hours) . $time;
         } else {
             $time = sprintf(dgettext('rss', '%d hours'), $hours) . $time;
         }
     }
     $refresh_time = sprintf(dgettext('rss', 'Every %s'), $time);
     $shortened_array = parse_url($this->address);
     $shortened = $shortened_array['scheme'] . '://' . $shortened_array['host'];
     $tpl['ADDRESS'] = sprintf('<a href="%s" title="%s">%s</a>', $this->address, $this->address, $shortened);
     $tpl['REFRESH_TIME'] = $refresh_time;
     return $tpl;
 }
Exemplo n.º 3
0
 public function getLink($addTitle = true)
 {
     if ($addTitle) {
         $title = $this->getTitle();
         $link = $this->getLink(false);
         $link_title = $this->getLinkTitle();
         if ($this->_strict) {
             return sprintf('<a href="%s"%s>%s</a>', $link, $link_title, $title);
         } elseif ($this->_secure) {
             $authkey = Current_User::getAuthKey();
             return sprintf('<a href="%s&amp;tab=%s&amp;authkey=%s"%s>%s</a>', $link, $this->id, $authkey, $link_title, $title);
         } else {
             return sprintf('<a href="%s&amp;tab=%s"%s>%s</a>', $link, $this->id, $link_title, $title);
         }
     } else {
         return $this->link;
     }
 }
Exemplo n.º 4
0
 private function newManagerSetup()
 {
     $development = false;
     if ($development) {
         $script_file = 'src/Signup.jsx';
         $type = 'text/jsx';
     } else {
         $script_file = 'build/Signup.js';
         $type = 'text/javascript';
     }
     $data['development'] = $development;
     $data['addons'] = true;
     javascript('react', $data);
     $script = '<script type="' . $type . '" src="' . PHPWS_SOURCE_HTTP . 'mod/properties/javascript/ManagerSignUp/' . $script_file . '"></script>';
     \Layout::addJSHeader($script);
     $vars['authkey'] = \Current_User::getAuthKey();
     $template = new \Template($vars);
     $template->setModuleTemplate('properties', 'ManagerSignUp.html');
     $this->title = 'New Manager Sign-Up';
     $this->content = $template->get();
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
    public function rowTags()
    {
        static $folder = null;
        if (empty($folder)) {
            $folder = new Folder($this->folder_id);
        }
        if (Current_User::allow('filecabinet', 'edit_folders', $this->folder_id, 'folder')) {
            if ($this->embedded) {
                $command = 'edit_rtmp';
            } else {
                $command = 'upload_multimedia_form';
            }
            //$links[] = $folder->uploadLink('icon', $this->id);
            //$authkey = \Current_User::getAuthKey(\PHPWS_Text::saltArray(array('mop'=>'delete_multimedia','file_id'=>$this->id)));
            $authkey = \Current_User::getAuthKey();
            $links[] = <<<EOF
<i style='cursor:pointer' class='fa fa-trash-o delete-file' data-folder-id='{$this->folder_id}' data-id='{$this->id}' data-type='mop' data-command='delete_multimedia' data-authkey='{$authkey}'></i>
EOF;
            //$links[] = $this->editLink(true);
            //$links[] = $this->deleteLink(true);
        }
        if (isset($links)) {
            $tpl['ACTION'] = implode('', $links);
        }
        $tpl['SIZE'] = $this->getSize(TRUE);
        $tpl['FILE_NAME'] = $this->file_name;
        $tpl['THUMBNAIL'] = $this->getJSView(true);
        $tpl['TITLE'] = $this->getJSView(false, $this->title);
        if ($this->isVideo()) {
            $tpl['DIMENSIONS'] = sprintf('%s x %s', $this->width, $this->height);
        }
        return $tpl;
    }
Exemplo n.º 8
0
 public function getAuthKey()
 {
     // if not secure, authkey irrelevant
     if (!$this->secure || !class_exists('Current_User')) {
         return null;
     }
     if ($this->salted) {
         // Have to make them strings because GET will change them on the
         // other side.
         return Current_User::getAuthKey(PHPWS_Text::saltArray($this->values));
     } else {
         $result = Current_User::getAuthKey();
         return $result;
     }
 }
Exemplo n.º 9
0
 public static function includeAuthkey()
 {
     static $authkey_inserted = false;
     if ($authkey_inserted) {
         return;
     } else {
         $authkey = \Current_User::getAuthKey();
         $script = "<script type='text/javascript'>var authkey='{$authkey}';</script>";
         \Layout::addJSHeader($script, 'authkey');
         $authkey_inserted = true;
     }
 }
Exemplo n.º 10
0
 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&amp;aop=delete_schedule&amp;sch_id=%s&amp;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;
 }
Exemplo n.º 11
0
 public function form()
 {
     $form = new \PHPWS_Form('photo-form');
     $form->addHidden('module', 'properties');
     if (isset($_SESSION['Contact_User'])) {
         $form->addHidden('cop', 'post_photo');
         $form->addHidden('k', $_SESSION['Contact_User']->getKey());
     } else {
         $form->addHidden('aop', 'post_photo');
     }
     if (isset($_GET['v'])) {
         $form->addHidden('v', 1);
     }
     $form->addHidden('pid', $_GET['pid']);
     $form->addText('title');
     $form->setLabel('title', 'Title');
     $form->addFile('photo');
     $form->addSubmit('submit', 'Upload photo');
     $tpl = $form->getTemplate();
     $tpl['WIDTH'] = PROP_THUMBNAIL_WIDTH;
     $tpl['HEIGHT'] = PROP_THUMBNAIL_HEIGHT;
     $tpl['AUTH'] = \Current_User::getAuthKey();
     $tpl['THUMBNAILS'] = Photo::getThumbs($_GET['pid']);
     if (isset($_SESSION['Contact_User'])) {
         $tpl['CMD'] = 'k=' . $_SESSION['Contact_User']->getKey() . '&cop';
     } else {
         $tpl['CMD'] = 'aop';
     }
     return \PHPWS_Template::process($tpl, 'properties', 'photo_form.tpl');
 }
Exemplo n.º 12
0
 public function pageList()
 {
     Layout::addStyle('pagesmith');
     PHPWS_Core::initCoreClass('DBPager.php');
     PHPWS_Core::initModClass('pagesmith', 'PS_Page.php');
     $pgtags['ACTION_LABEL'] = dgettext('pagesmith', 'Action');
     $createText = dgettext('pagesmith', 'New Page');
     $pgtags['NEW'] = "<a href='index.php?module=pagesmith&amp;aop=menu&amp;tab=new' class='button'>{$createText}/a>";
     if (PHPWS_Settings::get('pagesmith', 'text_only_default')) {
         $pgtags['NEW_PAGE_LINK_URI'] = 'index.php?module=pagesmith&aop=pick_template&tpl=text_only&pid=0&authkey=' . \Current_User::getAuthKey();
     } else {
         $pgtags['NEW_PAGE_LINK_URI'] = "index.php?module=pagesmith&amp;aop=menu&amp;tab=new";
     }
     $pgtags['NEW_PAGE_LINK_TEXT'] = $createText;
     $pager = new DBPager('ps_page', 'PS_Page');
     $pager->cacheQueries();
     $pager->addPageTags($pgtags);
     $pager->setModule('pagesmith');
     $pager->setTemplate('page_list.tpl');
     $pager->addRowTags('row_tags');
     $pager->setEmptyMessage(dgettext('pagesmith', 'No pages have been created.'));
     $pager->setSearch('title', 'id');
     $pager->addSortHeader('id', dgettext('pagesmith', 'Id'));
     $pager->addSortHeader('title', dgettext('pagesmith', 'Title'));
     $pager->addSortHeader('create_date', dgettext('pagesmith', 'Created'));
     $pager->addSortHeader('last_updated', dgettext('pagesmith', 'Updated'));
     $pager->addWhere('parent_page', 0);
     $pager->setDefaultLimit(10);
     $pager->setDefaultOrder('last_updated', 'desc');
     $this->ps->title = dgettext('pagesmith', 'Pages');
     $pager->initialize();
     $this->pullUpdated($pager);
     $this->ps->content = $pager->get();
 }
Exemplo n.º 13
0
 public static function shortcut_menu()
 {
     PHPWS_Core::initModClass('access', 'Shortcut.php');
     $sch_id = filter_input(INPUT_GET, 'sch_id', FILTER_SANITIZE_NUMBER_INT);
     if ($sch_id === false) {
         $sch_id = 0;
     }
     if (!$sch_id) {
         @($key_id = $_REQUEST['key_id']);
         if (!$key_id) {
             javascript('close_window');
             return;
         } else {
             $shortcut = new Access_Shortcut();
             $key = new Key($key_id);
             if (!$key->id) {
                 javascript('close_window');
                 return;
             }
             $shortcut->keyword = trim(preg_replace('/[^\\w\\s\\-]/', '', $key->title));
         }
     } else {
         $shortcut = new Access_Shortcut($sch_id);
         if (!$shortcut->id) {
             return 'Error: shortcut not found';
         }
     }
     $form = new \Form();
     $form->setAction('index.php');
     $form->appendCSS('bootstrap');
     $form->setId('shortcut-menu');
     $form->addHidden('authkey', \Current_User::getAuthKey());
     $form->addHidden('module', 'access');
     $form->addHidden('command', 'post_shortcut');
     if (isset($key_id)) {
         $form->addHidden('key_id', $key_id);
     } else {
         $form->addHidden('sch_id', $shortcut->id);
     }
     $keyword = $form->addTextField('keyword', $shortcut->keyword)->setRequired();
     $keyword->setPlaceholder(dgettext('access', 'Type in a keyword'));
     $tpl = $form->getInputStringArray();
     $template = new \Template($tpl);
     $template->setModuleTemplate('access', 'shortcut_menu.tpl');
     $content = $template->render();
     return $content;
 }
Exemplo n.º 14
0
 public static function sendMessage($message, $command)
 {
     $_SESSION['User_Admin_Message'] = $message;
     PHPWS_Core::reroute('index.php?module=users&action=admin&command=' . $command . '&authkey=' . Current_User::getAuthKey());
 }
Exemplo n.º 15
0
 public function assign()
 {
     Layout::addStyle('checkin');
     javascriptMod('checkin', 'send_note');
     javascriptMod('checkin', 'reassign', array('authkey' => Current_User::getAuthKey()));
     $this->title = dgettext('checkin', 'Assignment');
     $this->loadVisitorList(null, true);
     $this->loadStaffList(true);
     // id and name only for drop down menu
     $staff_list = $this->getStaffList(false, true, true);
     $staff_list = array_reverse($staff_list, true);
     $staff_list[0] = dgettext('checkin', 'Unassigned');
     $staff_list[-1] = dgettext('checkin', '-- Move visitor --');
     $staff_list = array_reverse($staff_list, true);
     if (empty($this->staff_list)) {
         $this->content = dgettext('checkin', 'No staff found.');
         return;
     }
     $status_list = $this->getStatusColors();
     // unassigned visitors
     $staff = new Checkin_Staff();
     $staff->display_name = dgettext('checkin', 'Unassigned');
     $row['VISITORS'] = $this->listVisitors($staff, $staff_list);
     $row['COLOR'] = '#ffffff';
     $row['DISPLAY_NAME'] = $staff->display_name;
     $tpl['rows'][] = $row;
     $count = 1;
     $backcount = -1;
     // Go through staff and list assignments
     foreach ($this->staff_list as $staff) {
         $row = array();
         $this->current_staff =& $staff;
         $row['VISITORS'] = $this->listVisitors($staff, $staff_list);
         $row['COLOR'] = $status_list[$staff->status];
         $row['DISPLAY_NAME'] = $staff->display_name;
         if (!isset($this->visitor_list[$staff->id])) {
             $this->current_visitor = null;
         } else {
             $this->current_visitor =& $this->visitor_list[$staff->id][0];
         }
         $this->statusButtons($row);
         if ($staff->status == 3) {
             $tpl['rows'][$backcount] = $row;
             $backcount--;
         } else {
             $tpl['rows'][$count] = $row;
             $count++;
         }
     }
     ksort($tpl['rows']);
     $tpl['VISITORS_LABEL'] = dgettext('checkin', 'Visitors');
     $tpl['DISPLAY_NAME_LABEL'] = dgettext('checkin', 'Staff name');
     $tpl['TIME_WAITING_LABEL'] = dgettext('checkin', 'Time waiting');
     $tpl['HIDE_PANEL'] = $this->hidePanelLink();
     $tpl['HIDE_SIDEBAR'] = $this->hideSidebarLink();
     $tpl['REFRESH'] = sprintf('<a href="index.php?module=checkin&tab=assign">%s</a>', dgettext('checkin', 'Refresh'));
     // UNASSIGN_ALL and AUTO_ASSIGN are links for testing functionality of automatic visitor assignment.
     //$tpl['UNASSIGN_ALL'] = sprintf('<a href="index.php?module=checkin&aop=unassignAll">%s</a>', dgettext('checkin', 'Unassign All')); // For testing purposes only
     //$tpl['AUTO_ASSIGN'] = sprintf('<a href="index.php?module=checkin&aop=auto_assign">%s</a>', dgettext('checkin', 'Auto Assign'));   // For testing purposes only
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'visitors.tpl');
     Layout::metaRoute('index.php?module=checkin&aop=assign', PHPWS_Settings::get('checkin', 'assign_refresh'));
 }
Exemplo n.º 16
0
    public function rowTags()
    {
        static $folder = null;
        if (empty($folder)) {
            $folder = new Folder($this->folder_id);
        }
        if (Current_User::allow('filecabinet', 'edit_folders', $this->folder_id, 'folder')) {
            $links[] = $folder->uploadLink('icon', null, null, $this->id);
            $authkey = \Current_User::getAuthKey(\PHPWS_Text::saltArray(array('iop' => 'delete_image', 'file_id' => $this->id, 'folder_id' => $this->folder_id)));
            $links[] = <<<EOF
<i style='cursor:pointer' class='fa fa-trash-o delete-file' data-folder-id='{$this->folder_id}' data-id='{$this->id}' data-type='iop' data-command='delete_image' data-authkey='{$authkey}'></i>
EOF;
        }
        if (isset($links)) {
            $tpl['ACTION'] = implode('', $links);
        }
        $tpl['SIZE'] = $this->getSize(TRUE);
        $tpl['FILE_NAME'] = $this->file_name;
        $tpl['THUMBNAIL'] = $this->lightboxThumb();
        $tpl['TITLE'] = htmlspecialchars($this->title, ENT_QUOTES);
        $tpl['DIMENSIONS'] = sprintf('%s x %s', $this->width, $this->height);
        return $tpl;
    }
Exemplo n.º 17
0
 /**
  *  Form for adding and choosing default authorization scripts
  */
 public static function authorizationSetup()
 {
     $template = array();
     PHPWS_Core::initCoreClass('File.php');
     $auth_list = User_Action::getAuthorizationList();
     $db = new PHPWS_DB('users_groups');
     $db->addOrder('name');
     $db->addColumn('name');
     $db->addColumn('id');
     $db->setIndexBy('id');
     $db->addWhere('user_id', 0);
     $groups = $db->select('col');
     if (PHPWS_Error::logIfError($groups)) {
         $groups = array(0 => dgettext('users', '- None -'));
     } else {
         $groups = array("0" => dgettext('users', '- None -')) + $groups;
     }
     foreach ($auth_list as $auth) {
         $file_compare[] = $auth['filename'];
     }
     $form = new PHPWS_Form();
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'admin');
     $form->addHidden('command', 'postAuthorization');
     $file_list = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'mod/users/scripts/', FALSE, TRUE, FALSE, array('php'));
     if (!empty($file_list)) {
         $remaining_files = array_diff($file_list, $file_compare);
     } else {
         $remaining_files = NULL;
     }
     if (empty($remaining_files)) {
         $template['FILE_LIST'] = dgettext('users', 'No new scripts found');
     } else {
         $form->addSelect('file_list', $remaining_files);
         $form->reindexValue('file_list');
         $form->addSubmit('add_script', dgettext('users', 'Add Script File'));
     }
     $form->mergeTemplate($template);
     $form->addSubmit('submit', dgettext('users', 'Update authorization scripts'));
     $template = $form->getTemplate();
     $template['AUTH_LIST_LABEL'] = dgettext('users', 'Authorization Scripts');
     $template['DEFAULT_LABEL'] = dgettext('users', 'Default');
     $template['DISPLAY_LABEL'] = dgettext('users', 'Display Name');
     $template['FILENAME_LABEL'] = dgettext('users', 'Script Filename');
     $template['DEFAULT_GROUP_LABEL'] = dgettext('users', 'Default group');
     $template['ACTION_LABEL'] = dgettext('users', 'Action');
     $default_authorization = PHPWS_User::getUserSetting('default_authorization');
     foreach ($auth_list as $authorize) {
         $links = array();
         extract($authorize);
         if ($default_authorization == $id) {
             $checked = 'checked="checked"';
         } else {
             $checked = NULL;
         }
         $getVars['module'] = 'users';
         $getVars['action'] = 'admin';
         $getVars['command'] = 'dropScript';
         if ($filename != 'local.php' && $filename != 'global.php') {
             $vars['QUESTION'] = dgettext('users', 'Are you sure you want to drop this authorization script?');
             $vars['ADDRESS'] = sprintf('index.php?module=users&action=admin&command=dropAuthScript&script_id=%s&authkey=%s', $id, Current_User::getAuthKey());
             $vars['LINK'] = dgettext('users', 'Drop');
             $links[1] = javascript('confirm', $vars);
         }
         $getVars['command'] = 'editScript';
         // May enable this later. No need for an edit link right now.
         //            $links[2] = PHPWS_Text::secureLink(dgettext('users', 'Edit'), 'users', $getVars);
         $row['CHECK'] = sprintf('<input type="radio" name="default_authorization" value="%s" %s />', $id, $checked);
         $form = new PHPWS_Form();
         $form->addSelect("default_group[{$id}]", $groups);
         $form->setMatch("default_group[{$id}]", $default_group);
         $row['DEFAULT_GROUP'] = $form->get("default_group[{$id}]");
         $row['DISPLAY_NAME'] = $display_name;
         $row['FILENAME'] = $filename;
         if (!empty($links)) {
             $row['ACTION'] = implode(' | ', $links);
         } else {
             $row['ACTION'] = dgettext('users', 'None');
         }
         $template['auth-rows'][] = $row;
     }
     return PHPWS_Template::process($template, 'users', 'forms/authorization.tpl');
 }
Exemplo n.º 18
0
 /**
  * Returns all the elements of a form in a template array
  *
  * This is the fruit of your labor. After calling this you will get an associative array
  * of all you form elements. The keys of the template are the capitalized names of the elements.
  * The template also includes START_FORM and END_FORM tags to make creating the form easier.
  * Hidden variables will AUTOMATICALLY be added to the START_FORM tag. If helperTags == false
  * they will be placed in a tag named HIDDEN.
  * It will also create a DEFAULT_SUBMIT button.
  *
  * Hidden variables will be added on to START_FORM. They will NOT have their own template tag.
  *
  * @author                     Matthew McNaney<mcnaney at gmail dot com>
  * @param  boolean phpws       If true and the action is missing, phpWebSite will attempt to use your directory settings instead
  * @param  boolean helperTags  If true START and END_FORM tags will be created, otherwise they will not
  * @param  array   template    If a current template is supplied, form will add to it.
  * @return array   template    Array of completed form
  */
 public function getTemplate($phpws = true, $helperTags = true, $template = null)
 {
     if (count($this->_elements) < 1) {
         return PHPWS_Error::get(PHPWS_FORM_NO_ELEMENTS, 'core', 'PHPWS_Form::getTemplate');
     }
     if (!is_null($template) && !is_array($template)) {
         return PHPWS_Error::get(PHPWS_FORM_NO_TEMPLATE, 'core', 'PHPWS_Form::getTemplate');
     }
     if ($helperTags) {
         $template['START_FORM'] = $this->getStart() . "\n";
         if ($this->use_fieldset) {
             $template['START_FORM'] .= "<fieldset class=\"phpws-form-container\">\n";
             $template['START_FORM'] .= '<legend>' . $this->legend . "</legend>\n";
         } else {
             $template['START_FORM'] .= "<div class=\"phpws-form-container\">\n";
         }
         if (FORM_USE_FILE_RESTRICTIONS && $this->_multipart) {
             $template['START_FORM'] .= sprintf('<input type="hidden" name="MAX_FILE_SIZE" value="%d" />', $this->max_file_size) . "\n";
         }
     }
     $template['FORM_ACTION'] = $this->getFormAction();
     $template['FORM_ID'] = $this->getFormId();
     $template['FORM_NAME'] = $this->getFormName();
     $template['FORM_AUTOCOMPLETE'] = $this->getAutocompleteValue();
     $template['FORM_CLASS'] = $this->getFormClass();
     $template['FORM_METHOD'] = $this->getMethod();
     $template['FORM_ENCODE'] = $this->getEncode();
     unset($this->_elements['authkey']);
     if (class_exists('Current_User') && $this->use_auth_key) {
         if ($authkey = Current_User::getAuthKey()) {
             $this->addHidden('authkey', $authkey);
         }
     }
     foreach ($this->_elements as $elementName => $element) {
         $multiple = false;
         $count = 1;
         $mult_count = 0;
         if (count($element) > 1) {
             $multiple = true;
         }
         if ($this->required_field) {
             $template['REQUIRED_LEGEND'] = '<span class="required-input">*</span> ' . _('Required field');
         }
         foreach ($element as $subElement) {
             $subtpl = array();
             if ($this->types[$elementName] == 'hidden') {
                 if ($helperTags) {
                     $template['START_FORM'] .= $subElement->get() . "\n";
                     if (!isset($template['HIDDEN_FIELDS'])) {
                         $template['HIDDEN_FIELDS'] = '';
                     }
                     $template['HIDDEN_FIELDS'] .= $subElement->get() . "\n";
                 } else {
                     $hidden_vars[] = $subElement->get();
                 }
                 continue;
             }
             $tagName = $subElement->getTag();
             $label = $subElement->getLabel(true);
             $labelText = $subElement->getLabel(false);
             if ($this->row_repeat && $multiple) {
                 if (!empty($label)) {
                     $subtpl[$tagName . '_LABEL'] = $label;
                     $subtpl[$tagName . '_LABEL_TEXT'] = $labelText;
                 }
                 $subtpl[$tagName] = $subElement->get();
                 $subtpl[$tagName . '_ID'] = $subElement->getId();
                 $template[strtolower($tagName) . '_repeat'][] = $subtpl;
                 continue;
             }
             if ($multiple) {
                 $tagName .= "_{$count}";
             }
             if (!empty($label)) {
                 $template[$tagName . '_LABEL'] = $label;
                 $template[$tagName . '_LABEL_TEXT'] = $labelText;
             }
             $template[$tagName . '_ID'] = $subElement->getId();
             $template[$tagName . '_VALUE'] = $subElement->value;
             // NB: Calling 'getValue()' gives 'value="myValue"'...
             $template[$tagName . '_NAME'] = $subElement->getName();
             $template[$tagName] = $subElement->get();
             $count++;
         }
     }
     if ($helperTags) {
         if ($this->use_fieldset) {
             $end_form[] = '</fieldset>';
         } else {
             $end_form[] = '</div>';
         }
         $end_form[] = '</form>';
         $template['END_FORM'] = implode("\n", $end_form);
     } elseif (isset($hidden_vars)) {
         $template['HIDDEN'] = implode("\n", $hidden_vars);
     }
     if (isset($this->_template)) {
         $template = array_merge($this->_template, $template);
     }
     if ($phpws == true) {
         return $template;
     } else {
         return implode("\n", $template);
     }
 }
Exemplo n.º 19
0
 /**
  * Directs the administrative choices
  * Content is displayed in main
  */
 public function direct()
 {
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = $this->panel->getCurrentTab();
     }
     switch ($command) {
         case 'new':
             $this->resetAdmin();
             $this->edit_db();
             break;
         case 'edit':
             // editing existing branch
             if (empty($this->branch->id)) {
                 $this->content = dgettext('branch', 'Incorrect or missing branch id.');
             }
             break;
         case 'list':
             // list all branches in the system
             $this->listBranches();
             break;
         case 'post_db':
             // post a new or updated branch to the system
             if (isset($_POST['plug'])) {
                 // user is going to use the hub dsn information
                 $this->plugHubValues();
                 $this->edit_db();
             } else {
                 if (!$this->post_db()) {
                     $this->edit_db();
                 } else {
                     $this->testDB(!empty($_POST['force']));
                 }
             }
             break;
         case 'edit_branch':
             $this->edit_basic();
             break;
         case 'post_basic':
             if (!$this->branch->id) {
                 $new_branch = true;
             } else {
                 $new_branch = false;
             }
             if (!$this->post_basic()) {
                 $this->edit_basic();
             } else {
                 $result = $this->branch->save();
                 if (PHPWS_Error::isError($result)) {
                     PHPWS_Error::log($result);
                     $this->title = dgettext('branch', 'An error occurred while saving your branch.');
                     $this->content = $result->getMessage();
                     return;
                 }
                 if ($new_branch) {
                     if ($this->branch->createDirectories()) {
                         $this->setCreateStep(3);
                         $this->title = dgettext('branch', 'Create branch directories');
                         $this->message[] = dgettext('branch', 'Branch created successfully.');
                         $this->install_branch_core();
                     } else {
                         $this->title = dgettext('branch', 'Unable to create branch directories.');
                         $this->content = dgettext('branch', 'Sorry, but Branch failed to make the proper directories.');
                     }
                 } else {
                     $this->listBranches();
                 }
             }
             break;
         case 'install_branch_core':
             $this->install_branch_core();
             break;
         case 'core_module_installation':
             $result = $this->core_module_installation();
             if ($result) {
                 $this->content[] = dgettext('branch', 'All done!');
                 $this->resetAdmin();
             } elseif ($_SESSION['Boost']->currentDone()) {
                 $meta = sprintf('index.php?module=branch&command=core_module_installation&branch_id=%s&authkey=%s', $this->branch->id, Current_User::getAuthKey());
                 Layout::metaRoute($meta);
             }
             break;
         case 'remove_branch':
             if (isset($_REQUEST['branch_id']) && isset($_REQUEST['branch_name']) && $this->branch->branch_name === $_REQUEST['branch_name']) {
                 $this->branch->delete();
             }
             $this->listBranches();
             break;
         case 'force_install':
             $this->setCreateStep(2);
             $this->saveDSN();
             $this->message[] = dgettext('branch', 'Connection successful. Database available.');
             $this->edit_basic();
             break;
     }
     // end of the command switch
 }
Exemplo n.º 20
0
    /**
     * Lists the contents of a folder for adminstrative changes.
     * @param object $folder
     * @param boolean $pick_image
     */
    public function folderContents($folder)
    {
        $links = array();
        javascript('jquery');
        $src = PHPWS_SOURCE_HTTP . 'mod/filecabinet/javascript/folder_options/contents.js';
        \Layout::addJSHeader("<script type='text/javascript' src='{$src}'></script>", 'folder-options');
        Layout::addStyle('filecabinet');
        PHPWS_Core::initCoreClass('DBPager.php');
        $dir_write = true;
        if (!is_writable($folder->getFullDirectory())) {
            $this->cabinet->message .= dgettext('filecabinet', 'Warning: this folder\'s directory is not writable.');
            $dir_write = false;
        }
        if ($folder->ftype == IMAGE_FOLDER) {
            javascript('lightbox');
            PHPWS_Core::initModClass('filecabinet', 'Image.php');
            $pager = new DBPager('images', 'PHPWS_Image');
            $pager->setTemplate('Forms/image_grid.tpl');
            $limits[9] = 9;
            $limits[16] = 16;
            $limits[25] = 25;
            $operation = 'iop';
            $command = 'upload_image_form';
            $label = _('Add image');
        } elseif ($folder->ftype == DOCUMENT_FOLDER) {
            PHPWS_Core::initModClass('filecabinet', 'Document.php');
            $pager = new DBPager('documents', 'PHPWS_Document');
            $pager->setTemplate('Forms/file_list.tpl');
            $limits[10] = 10;
            $limits[25] = 25;
            $limits[50] = 50;
            $operation = 'dop';
            $label = _('Add document');
            $command = 'upload_document_form';
            $pager->addSortHeader('downloaded', sprintf('<abbr title="%s">%s</abbr>', dgettext('filecabinet', 'Downloaded'), dgettext('filecabinet', 'DL')));
        } elseif ($folder->ftype = MULTIMEDIA_FOLDER) {
            PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
            $pager = new DBPager('multimedia', 'PHPWS_Multimedia');
            $pager->setTemplate('Forms/multimedia_grid.tpl');
            $limits[9] = 9;
            $limits[16] = 16;
            $limits[25] = 25;
            $label = _('Add media');
            $command = 'upload_multimedia_form';
            $operation = 'mop';
        }
        if (Current_User::allow('filecabinet', 'edit_folders', $folder->id, 'folder')) {
            if ($dir_write) {
                $links[] = $folder->uploadLink('button');
            }
            if ($folder->ftype == MULTIMEDIA_FOLDER) {
                //$links[] = $folder->rtmpLink();
                $salt = array('mop' => 'edit_rtmp', 'folder_id' => $folder->id);
                $authkey = \Current_User::getAuthKey(PHPWS_Text::saltArray($salt));
                $links[] = <<<EOF
<button class="btn btn-default show-modal" data-authkey="{$authkey}" data-command="edit_rtmp" data-operation="{$operation}" data-folder-id="{$folder->id}"><i class="fa fa-cloud"></i> Add RTMP video</button>
EOF;
            }
            //$links[] = $folder->editLink();
            $salt = array($operation => 'edit_folder', 'folder_id' => $folder->id);
            $authkey = \Current_User::getAuthKey(PHPWS_Text::saltArray($salt));
            $links[] = <<<EOF
<button class="btn btn-default show-modal" data-authkey="{$authkey}" data-command="edit_folder_modal" data-operation="aop" data-folder-id="{$folder->id}"><i class="fa fa-edit"></i> Edit</button>
EOF;
        }
        if ($this->cabinet->panel) {
            $pagetags['BACK'] = PHPWS_Text::moduleLink('<i class="fa fa-reply"></i> ' . dgettext('filecabinet', 'Back to folder list'), 'filecabinet', array('tab' => $this->cabinet->panel->getCurrentTab()), null, null, 'btn btn-default');
        }
        if (!empty($links)) {
            $pagetags['ADMIN_LINKS'] = implode(' ', $links);
        }
        $pagetags['MODAL'] = $this->getModal();
        $pagetags['ACTION_LABEL'] = dgettext('filecabinet', 'Action');
        $pager->setLimitList($limits);
        $pager->setSearch('file_name', 'title', 'description');
        $pager->addWhere('folder_id', $folder->id);
        $pager->setOrder('title', 'asc', true);
        $pager->setModule('filecabinet');
        $pager->addPageTags($pagetags);
        $pager->addRowTags('rowTags');
        $pager->addSortHeader('title', dgettext('filecabinet', 'Title'));
        $pager->addSortHeader('file_name', dgettext('filecabinet', 'File name'));
        $pager->addSortHeader('file_type', dgettext('filecabinet', 'File type'));
        $pager->addSortHeader('size', dgettext('filecabinet', 'Size'));
        $pager->setEmptyMessage(dgettext('filecabinet', 'Folder is empty.'));
        $this->cabinet->content = $pager->get();
    }
Exemplo n.º 21
0
<?php

/**
 * @author Matt McNaney <mcnaney at gmail dot com>
 */
javascript('jquery_ui');
$data['auth'] = Current_User::getAuthKey();
Exemplo n.º 22
0
 private function viewContactApprovals()
 {
     $development = false;
     if ($development) {
         $script_file = 'src/Approval.jsx';
         $type = 'text/jsx';
     } else {
         $script_file = 'build/Approval.js';
         $type = 'text/javascript';
     }
     $data['development'] = $development;
     $data['addons'] = false;
     javascript('react', $data);
     $script = '<script type="' . $type . '" src="' . PHPWS_SOURCE_HTTP . 'mod/properties/javascript/ContactApproval/' . $script_file . '"></script>' . '<script type="text/javascript">var authkey="' . \Current_User::getAuthkey() . '";</script>';
     \Layout::addJSHeader($script);
     $vars['authkey'] = \Current_User::getAuthKey();
     $template = new \Template($vars);
     $template->setModuleTemplate('properties', 'ManagerSignUp.html');
     $this->title = 'Contact Approval';
     $this->content = '<div id="ContactApproval"></div>';
 }
Exemplo n.º 23
0
 public static function admin()
 {
     if (!Current_User::allow('layout')) {
         Current_User::disallow();
     }
     PHPWS_Core::initModClass('controlpanel', 'Panel.php');
     $title = $content = null;
     $panel = Layout_Admin::adminPanel();
     if (isset($_REQUEST['command'])) {
         $command = $_REQUEST['command'];
     } else {
         $command = $panel->getCurrentTab();
     }
     switch ($command) {
         case 'arrange':
             $title = dgettext('layout', 'Arrange Layout');
             $content[] = Layout_Admin::arrangeForm();
             break;
         case 'turn_off_box_move':
             Layout::moveBoxes(false);
             PHPWS_Core::goBack();
             break;
         case 'post_style_change':
             $result = Layout_Admin::postStyleChange();
             if (PHPWS_Error::isError($result)) {
                 PHPWS_Error::log($result);
             }
             javascript('close_refresh');
             break;
         case 'reset_boxes':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::resetDefaultBoxes();
             unset($_SESSION['Layout_Settings']);
             PHPWS_Core::reroute('index.php?module=layout&action=admin&authkey=' . Current_User::getAuthKey());
             break;
         case 'move_boxes_on':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::moveBoxes(true);
             PHPWS_Core::goBack();
             break;
         case 'move_boxes_off':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout::moveBoxes(false);
             PHPWS_Core::goBack();
             break;
         case 'confirmThemeChange':
             $title = dgettext('layout', 'Themes');
             if (isset($_POST['confirm'])) {
                 Layout_Admin::changeTheme();
                 PHPWS_Core::reroute('index.php?module=layout&action=admin&tab=theme');
                 exit;
             } else {
                 Layout::reset();
             }
             $content[] = Layout_Admin::adminThemes();
             break;
         case 'meta':
             $title = dgettext('layout', 'Edit Meta Tags');
             $content[] = Layout_Admin::metaForm();
             break;
         case 'clear_templates':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             $files = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'templates/cache', false, true);
             if (!empty($files) && is_array($files)) {
                 foreach ($files as $fn) {
                     $delete_cache_path = "templates/cache/{$fn}";
                     if (is_file($delete_cache_path)) {
                         unlink('templates/cache/' . $fn);
                     }
                 }
             }
             PHPWS_Core::goBack();
             break;
         case 'clear_cache':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             PHPWS_Cache::clearCache();
             PHPWS_Core::goBack();
             break;
         case 'moveBox':
             $result = Layout_Admin::moveBox();
             PHPWS_Error::logIfError($result);
             javascript('close_refresh');
             Layout::nakedDisplay();
             break;
         case 'postMeta':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout_Admin::postMeta();
             if (isset($_POST['key_id'])) {
                 javascript('close_refresh');
                 Layout::nakedDisplay();
                 exit;
             }
             Layout::reset();
             $title = dgettext('layout', 'Edit Meta Tags');
             $template['MESSAGE'] = dgettext('layout', 'Meta Tags updated.');
             $content[] = Layout_Admin::metaForm();
             break;
         case 'demo_fail':
             unset($_SESSION['Layout_Settings']);
             Layout::checkSettings();
             PHPWS_Core::reroute('index.php?module=layout&amp;action=admin&amp;command=confirmThemeChange');
             break;
         case 'demo_theme':
             $title = dgettext('layout', 'Confirm Theme Change');
             $content[] = dgettext('layout', 'If you are happy with the change, click the appropiate button.');
             $content[] = dgettext('layout', 'Failure to respond in ten seconds, reverts phpWebSite to the default theme.');
             $content[] = Layout_Admin::confirmThemeChange();
             break;
         case 'postTheme':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             if ($_POST['default_theme'] != $_SESSION['Layout_Settings']->current_theme) {
                 Layout::reset($_POST['default_theme']);
                 PHPWS_Core::reroute('index.php?module=layout&action=admin&command=demo_theme&authkey=' . Current_User::getAuthKey());
             } else {
                 PHPWS_Settings::set('layout', 'include_css_order', (int) $_POST['include_css_order']);
                 PHPWS_Settings::save('layout');
                 $title = dgettext('layout', 'Themes');
                 $content[] = Layout_Admin::adminThemes();
             }
             break;
         case 'theme':
             $title = dgettext('layout', 'Themes');
             $content[] = Layout_Admin::adminThemes();
             break;
         case 'js_style_change':
             $content = Layout_Admin::jsStyleChange();
             if (empty($content)) {
                 javascript('close_refresh');
             }
             Layout::nakedDisplay($content, dgettext('layout', 'Change CSS'));
             break;
         case 'page_meta_tags':
             $content = Layout_Admin::pageMetaTags((int) $_REQUEST['key_id']);
             if (empty($content)) {
                 javascript('close_refresh');
             }
             Layout::nakedDisplay($content, dgettext('layout', 'Set meta tags'));
             break;
         case 'move_popup':
             if (!Current_User::authorized('layout')) {
                 Current_User::disallow();
             }
             Layout_Admin::moveBoxMenu();
             break;
     }
     $template['TITLE'] = $title;
     if (isset($content)) {
         $template['CONTENT'] = implode('<br />', $content);
     }
     if (isset($message)) {
         $template['MESSAGE'] = $message;
     }
     $final = PHPWS_Template::process($template, 'layout', 'main.tpl');
     $panel->setContent($final);
     Layout::add(PHPWS_ControlPanel::display($panel->display()));
 }
Exemplo n.º 24
0
 public static function panelLink($fly_out = false)
 {
     Layout::addStyle('controlpanel', 'panel_link.css');
     $reg_link = PHPWS_Text::quickLink(dgettext('controlpanel', 'Control Panel'), 'controlpanel', array('command' => 'panel_view'));
     if (!$fly_out) {
         return $reg_link->get();
     }
     javascript('jquery');
     javascriptMod('controlpanel', 'subpanel');
     $reg_link->setId('cp-panel-link');
     $all_tabs = PHPWS_ControlPanel::loadTabs();
     $all_links = PHPWS_ControlPanel::getAllLinks(true);
     $tpl = new PHPWS_Template('controlpanel');
     $tpl->setFile('subpanel.tpl');
     $authkey = Current_User::getAuthKey();
     if (!empty($all_links)) {
         foreach ($all_links as $tab => $links) {
             foreach ($links as $link) {
                 $tpl->setCurrentBlock('links');
                 $tpl->setData(array('LINK' => sprintf('<a href="%s&amp;authkey=%s">%s</a>', $link->url, $authkey, str_replace(' ', '&#160;', $link->label))));
                 $tpl->parseCurrentBlock();
             }
             $tab_link = $all_tabs[$tab]->link . '&amp;tab=' . $all_tabs[$tab]->id;
             $tpl->setCurrentBlock('tab');
             $tpl->setData(array('TAB_TITLE' => sprintf('<a href="%s">%s</a>', $tab_link, $all_tabs[$tab]->title)));
             $tpl->parseCurrentBlock();
         }
     }
     $tpl->setCurrentBlock();
     $tpl->setData(array('CP_LINK' => $reg_link->get()));
     $tpl->parseCurrentBlock();
     $submenu = $tpl->get();
     return $submenu;
 }
Exemplo n.º 25
0
 /**
  * View of files in current folder
  */
 public function folderContentView()
 {
     javascript('jquery');
     PHPWS_Core::initModClass('filecabinet', 'Image.php');
     javascript('confirm');
     // needed for deletion
     Layout::addStyle('filecabinet');
     if (empty($this->current_folder) || empty($this->folder_type)) {
         javascript('alert', array('content' => dgettext('filecabinet', 'Problem with opening browser page. Closing File Manager window.')));
         javascript('close_refresh', array('timeout' => 3, 'refresh' => 0));
         return;
     }
     $tpl = array();
     $this->folderIcons($tpl);
     if (Current_User::allow('filecabinet', 'edit_folders')) {
         $tpl['FOLDER_TITLE'] = $this->current_folder->editLink('title', $this->current_folder->module_created);
     } else {
         $tpl['FOLDER_TITLE'] =& $this->current_folder->title;
     }
     $img_dir = PHPWS_SOURCE_HTTP . 'mod/filecabinet/img/file_manager/';
     $image_string = '<img src="%s" title="%s" alt="%s" />';
     $link_info = $this->linkInfo();
     switch ($this->folder_type) {
         case IMAGE_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize image.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This image is larger than the %s x %s limit. Do you want to resize the image to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             $db = new PHPWS_DB('images');
             $class_name = 'PHPWS_Image';
             $file_type = FC_IMAGE;
             $altvars = $link_info;
             // check
             unset($altvars['mw']);
             unset($altvars['mh']);
             unset($altvars['fr']);
             $img1 = 'folder_random.png';
             $img2 = 'thumbnails.png';
             $img3 = 'lightbox.png';
             $img1_alt = dgettext('filecabinet', 'Random image icon');
             $img2_alt = dgettext('filecabinet', 'Thumbnail icon');
             $img3_alt = dgettext('filecabinet', 'Lightbox icon');
             if (!$this->reserved_folder) {
                 if ($this->current_folder->public_folder) {
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_IMAGE_RANDOM;
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     if (!$this->lock_type || in_array(FC_IMAGE_RANDOM, $this->lock_type)) {
                         $img1_title = dgettext('filecabinet', 'Show a random image from this folder');
                         $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                         $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                         if ($this->file_assoc->file_type == FC_IMAGE_RANDOM && $this->current_folder->id == $this->file_assoc->file_id) {
                             $tpl['ALT_HIGH1'] = ' alt-high';
                         }
                     } else {
                         $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                         $tpl['ALT1'] = $image1;
                         $tpl['ALT_HIGH1'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_FOLDER, $this->lock_type)) {
                         /** start new * */
                         if ($this->file_assoc->file_type == FC_IMAGE_FOLDER) {
                             $tpl['ALT_HIGH2'] = ' alt-high';
                         }
                         $img2_title = dgettext('filecabinet', 'Show block of thumbnails');
                         $image2 = sprintf($image_string, $img_dir . $img2, $img2_title, $img2_alt);
                         $form = new PHPWS_Form('carousel-options');
                         $form->setMethod('get');
                         $altvars['file_type'] = FC_IMAGE_FOLDER;
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8);
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Carousel direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return carousel_pick();">%s</a>', $image2);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT2'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/carousel_pick.tpl');
                     } else {
                         $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                         $tpl['ALT2'] = $image2;
                         $tpl['ALT_HIGH2'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_LIGHTBOX, $this->lock_type)) {
                         /** start VV * */
                         if ($this->file_assoc->file_type == FC_IMAGE_LIGHTBOX) {
                             $tpl['ALT_HIGH3'] = ' alt-high';
                         }
                         $img3_title = dgettext('filecabinet', 'Show lightbox slideshow');
                         $image3 = sprintf($image_string, $img_dir . $img3, $img3_title, $img3_alt);
                         $altvars['file_type'] = FC_IMAGE_LIGHTBOX;
                         $form = new PHPWS_Form('lightbox-options');
                         $form->setMethod('get');
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(3 => 3, 6 => 6, 9 => 9, 12 => 12, 15 => 15, 18 => 18, 21 => 21, 99 => 'unlimited');
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Thumbnail direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return lightbox_pick();">%s</a>', $image3);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT3'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/lightbox_pick.tpl');
                     } else {
                         $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                         $tpl['ALT3'] = $image3;
                         $tpl['ALT_HIGH3'] = ' no-use';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                     $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                     $tpl['ALT2'] = $image2;
                     $tpl['ALT_HIGH2'] = ' no-use';
                     $tpl['ALT3'] = $image3;
                     $tpl['ALT_HIGH3'] = ' no-use';
                 }
             }
             break;
         case DOCUMENT_FOLDER:
             PHPWS_Core::initModClass('filecabinet', 'Document.php');
             $db = new PHPWS_DB('documents');
             $class_name = 'PHPWS_Document';
             $file_type = FC_DOCUMENT;
             $img1 = 'all_files.png';
             $img1_alt = dgettext('filecabinet', 'All files icon');
             if ($this->current_folder->public_folder) {
                 if (!$this->lock_type || in_array(FC_DOCUMENT_FOLDER, $this->lock_type)) {
                     $altvars = $link_info;
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_DOCUMENT_FOLDER;
                     $img1_title = dgettext('filecabinet', 'Show all files in the folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                     $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                     if ($this->file_assoc->file_type == FC_DOCUMENT_FOLDER && $this->current_folder->id == $this->file_assoc->file_id) {
                         $tpl['ALT_HIGH1'] = ' alt-high';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                 }
             } else {
                 $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                 $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                 $tpl['ALT1'] = $image1;
                 $tpl['ALT_HIGH1'] = ' no-use';
             }
             break;
         case MULTIMEDIA_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize media.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This media is larger than the %s x %s limit. Do you want to resize the media to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
             $db = new PHPWS_DB('multimedia');
             $class_name = 'PHPWS_Multimedia';
             $file_type = FC_MEDIA;
             //$tpl['ADD_EMBED'] = $this->current_folder->embedLink(true);
             break;
     }
     $db->addWhere('folder_id', $this->current_folder->id);
     $db->addOrder('title');
     $items = $db->getObjects($class_name);
     if ($items) {
         foreach ($items as $item) {
             $stpl = $item->managerTpl($this);
             $tpl['items'][] = $stpl;
         }
     } else {
         $not_allowed = dgettext('filecabinet', 'No files in folder');
         if (isset($tpl['ALT1'])) {
             $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
             $tpl['ALT1'] = $image1;
             $tpl['ALT_HIGH1'] = ' no-use';
         }
         if (isset($tpl['ALT2'])) {
             $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
             $tpl['ALT2'] = $image2;
             $tpl['ALT_HIGH2'] = ' no-use';
         }
     }
     if (Current_User::allow('filecabinet', 'edit_folders', $this->current_folder->id, 'folder')) {
         if ($this->force_upload_dimensions) {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true, $this->max_width, $this->max_height);
         } else {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true);
         }
     }
     $tpl['CLOSE'] = javascript('close_window');
     return PHPWS_Template::process($tpl, 'filecabinet', 'file_manager/folder_content_view.tpl');
 }
Exemplo n.º 26
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
Block::show();
if (Current_User::allow('block')) {
    $key = Key::getCurrent();
    if (Key::checkKey($key) && javascriptEnabled()) {
        javascript('jquery');
        javascript('ckeditor');
        $js_address = PHPWS_SOURCE_HTTP . 'mod/block/javascript/addblock/script.js';
        Layout::addJSHeader('<script src="' . $js_address . '" type="text/javascript"></script>', 'addblock');
        $modal = new \Modal('block-form-modal', '<div id="block-form-dialog"></div>', 'Add block here');
        $modal->sizeLarge();
        $save_button = '<button class="btn btn-success" id="save-block">Save</button>';
        $modal->addButton($save_button);
        Layout::add((string) $modal);
        MiniAdmin::add('block', '<a style="cursor:pointer" data-auth-key="' . Current_User::getAuthKey() . '" data-key-id="' . $key->id . '" id="add-block"><i class="fa fa-plus"></i> Add block here</a>');
    }
}
Exemplo n.º 27
0
 public static function sendMessage($message, $command)
 {
     $_SESSION['RSS_Message'] = $message;
     PHPWS_Core::reroute(sprintf('index.php?module=rss&command=%s&authkey=%s', $command, Current_User::getAuthKey()));
 }
Exemplo n.º 28
0
 public function getUrl($tag = false, $relative = false)
 {
     if ($this->restricted) {
         $authkey = '&amp;authkey=' . Current_User::getAuthKey();
     } else {
         $authkey = null;
     }
     $relurl = $this->url . $authkey;
     if ($tag) {
         return sprintf('<a href="%s">%s</a>', $relurl, $this->getLabel());
     } else {
         if ($relative) {
             return $relurl;
         } else {
             return $this->url;
         }
     }
 }
Exemplo n.º 29
0
 /**
  * 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;
 }
Exemplo n.º 30
0
 public function adminMenu()
 {
     if (!Current_User::allow('signup')) {
         Current_User::disallow();
     }
     $this->loadPanel();
     $javascript = false;
     $this->loadMessage();
     $command = $_REQUEST['aop'];
     switch ($command) {
         case 'add_slot_peep':
             $javascript = true;
             $this->loadPeep();
             $this->loadForm('edit_peep');
             break;
         case 'menu':
             if (!isset($_GET['tab'])) {
                 $this->loadForm('list');
             } else {
                 $this->loadForm($_GET['tab']);
             }
             break;
         case 'delete_sheet':
             $this->loadSheet();
             $this->sheet->delete();
             $this->message = dgettext('signup', 'Signup sheet deleted.');
             $this->loadForm('list');
             break;
         case 'edit_sheet':
             $this->loadForm('edit_sheet');
             break;
         case 'edit_slot_peep':
             $javascript = true;
             $this->loadPeep();
             $this->loadForm('edit_peep');
             break;
         case 'edit_slot_popup':
             $javascript = true;
             $this->loadSlot();
             $this->loadForm('edit_slot_popup');
             break;
         case 'edit_peep_popup':
             $javascript = true;
             $this->loadSlot();
             $this->loadForm('edit_peep_popup');
             break;
         case 'print_applicants':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->printApplicants();
             exit;
             break;
         case 'email_applicants':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadEmail();
             $this->loadSheet();
             $this->loadForm('email_applicants');
             break;
         case 'post_email':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadEmail();
             $this->loadSheet();
             if ($this->postEmail()) {
                 $this->sendEmail();
             } else {
                 $this->loadForm('email_applicants');
             }
             break;
         case 'slot_listing':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->slotListing();
             exit;
             break;
         case 'csv_applicants':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->csvExport();
             exit;
             break;
         case 'send_email':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->sendEmail();
             break;
         case 'edit_slots':
             $this->loadSheet();
             $this->loadForm('edit_slots');
             break;
         case 'search_slot':
             $this->searchSlots();
             break;
         case 'post_peep':
             $javascript = true;
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             if ($this->postPeep()) {
                 // Since added by an admin, automatically registered
                 $this->peep->registered = 1;
                 if (PHPWS_Error::logIfError($this->peep->save())) {
                     $this->forwardMessage(dgettext('signup', 'Error occurred when saving applicant.'));
                 } else {
                     $this->forwardMessage(dgettext('signup', 'Applicant saved successfully.'));
                 }
                 javascript('close_refresh');
                 Layout::nakedDisplay();
             } else {
                 $this->loadForm('edit_peep');
             }
             break;
         case 'post_sheet':
             $this->loadSheet();
             if (!Current_User::authorized('signup', 'edit_sheet', $this->sheet->id, 'sheet')) {
                 Current_User::disallow();
             }
             if ($this->postSheet()) {
                 if (!$this->sheet->id && PHPWS_Core::isPosted()) {
                     $this->message = dgettext('signup', 'Sheet previously posted.');
                     $this->loadForm('edit_sheet');
                 } else {
                     $new_sheet = !$this->sheet->id;
                     if (PHPWS_Error::logIfError($this->sheet->save())) {
                         $this->forwardMessage(dgettext('signup', 'Error occurred when saving sheet.'));
                         PHPWS_Core::reroute('index.php?module=signup&aop=list');
                     } else {
                         $this->forwardMessage(dgettext('signup', 'Sheet saved successfully.'));
                         if ($new_sheet) {
                             PHPWS_Core::reroute('index.php?module=signup&aop=edit_slots&sheet_id=' . $this->sheet->id);
                         } else {
                             $this->loadForm('list');
                         }
                     }
                 }
             } else {
                 $this->loadForm('edit_sheet');
             }
             break;
         case 'post_slot':
             $javascript = true;
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             if ($this->postSlot()) {
                 if (PHPWS_Error::logIfError($this->slot->save())) {
                     $this->forwardMessage(dgettext('signup', 'Error occurred when saving slot.'));
                 } else {
                     $this->forwardMessage(dgettext('signup', 'Slot saved successfully.'));
                 }
                 javascript('close_refresh');
                 Layout::nakedDisplay();
             } else {
                 $this->loadForm('edit_slot_popup');
             }
             break;
         case 'move_peep':
             $this->loadPeep();
             $result = $this->movePeep();
             if (PHPWS_Error::logIfError($result) || !$result) {
                 $this->forwardMessage(dgettext('signup', 'Error occurred when moving applicant. Slot may be full.'));
             }
             PHPWS_Core::goBack();
             break;
         case 'move_top':
             $this->loadSlot();
             $this->slot->moveTop();
             PHPWS_Core::goBack();
             break;
         case 'move_up':
             $this->loadSlot();
             $this->slot->moveUp();
             PHPWS_Core::goBack();
             break;
         case 'move_down':
             $this->loadSlot();
             $this->slot->moveDown();
             PHPWS_Core::goBack();
             break;
         case 'move_bottom':
             $this->loadSlot();
             $this->slot->moveBottom();
             PHPWS_Core::goBack();
             break;
         case 'delete_slot':
             $this->loadSlot();
             $this->deleteSlot();
             break;
         case 'delete_slot_peep':
             $this->loadPeep();
             $this->peep->delete();
             PHPWS_Core::goBack();
             break;
         case 'report':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->loadForm('report');
             break;
         case 'alpha_order':
         case 'reset_slot_order':
             if (!Current_User::authorized('signup')) {
                 Current_User::disallow();
             }
             $this->loadSheet();
             $this->resetSlots($command);
             $this->forwardMessage(dgettext('signup', 'Slot order reset.'));
             PHPWS_Core::reroute('index.php?module=signup&sheet_id=' . $this->sheet->id . '&aop=edit_slots&authkey=' . Current_User::getAuthKey());
             break;
     }
     $tpl['TITLE'] = $this->title;
     $tpl['CONTENT'] = $this->content;
     $tpl['MESSAGE'] = $this->message;
     if ($javascript) {
         $fonts = '<link rel="stylesheet" type="text/css" href="' . PHPWS_SOURCE_HTTP . 'themes/bootstrap/font-awesome/css/font-awesome.min.css" />
         <link rel="stylesheet" type="text/css" href="' . PHPWS_SOURCE_HTTP . 'themes/bootstrap/css/bootstrap.min.css" />';
         \Layout::addJSHeader($fonts);
         Layout::nakedDisplay(PHPWS_Template::process($tpl, 'signup', 'main.tpl'));
     } else {
         $this->panel->setContent(PHPWS_Template::process($tpl, 'signup', 'main.tpl'));
         Layout::add(PHPWS_ControlPanel::display($this->panel->display()));
     }
 }