예제 #1
0
 /**
  * Report lists rooms in each residence hall that are still available, along with
  * the available beds in the room.  Also, show the number of beds allocated to the
  * lotter for each residence hall.
  *
  */
 public static function reappAvailability()
 {
     $term = Term::getSelectedTerm();
     // Available rooms in each residence hall.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     //$db->addWhere('hms_bed.ra_bed', 0);
     $db->addWhere('hms_room.private', 0);
     $db->addWhere('hms_room.overflow', 0);
     $db->addWhere('hms_room.reserved', 0);
     $db->addWhere('hms_room.offline', 0);
     $db->addWhere('hms_bed.term', $term);
     $db->addColumn('hms_room.room_number');
     $db->addColumn('hms_bed.bed_letter', null, null, True);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->addGroupBy('hms_room.room_number');
     $db->addOrder('hms_residence_hall.hall_name');
     $availRooms = $db->select();
     // Allocated beds for lottery.
     $db = new PHPWS_DB('hms_bed');
     $db->addJoin('LEFT', 'hms_bed', 'hms_room', 'room_id', 'id');
     $db->addJoin('LEFT', 'hms_room', 'hms_floor', 'floor_id', 'id');
     $db->addJoin('LEFT', 'hms_floor', 'hms_residence_hall', 'residence_hall_id', 'id');
     $db->addJoin('RIGHT', 'hms_bed', 'hms_lottery_reservation', 'id', 'bed_id');
     $db->addWhere('hms_lottery_reservation.term', $term);
     $db->addColumn('hms_residence_hall.hall_name');
     $db->addColumn('hms_bed.id', null, null, True);
     $db->addGroupBy('hms_residence_hall.hall_name');
     $db->setIndexBy('hall_name');
     $lotteryBeds = $db->select();
     $tpl = new PHPWS_Template('hms');
     $tpl->setFile('admin/reports/reapp_availability.tpl');
     //
     // "The parent row must be parsed after the child rows."
     // Preload currHall with first residence hall name
     $currHall = $availRooms[0]['hall_name'];
     foreach ($availRooms as $row) {
         // Change halls, create new block.
         if ($currHall != $row['hall_name'] || $currHall == null) {
             $tpl->setCurrentBlock('halls');
             // Get allocated beds for the residence hall.
             $lottCount = isset($lotteryBeds[$currHall]['count']) ? $lotteryBeds[$currHall]['count'] : 0;
             $tpl->setData(array('HALL_NAME' => $currHall, 'LOTTERY_BEDS' => $lottCount));
             $tpl->parseCurrentBlock();
             $currHall = $row['hall_name'];
         }
         // Add room to residence hall template block.
         $tpl->setCurrentBlock('rooms');
         $tpl->setData(array('ROOM_NUM' => $row['room_number'], 'BED_COUNT' => $row['count']));
         $tpl->parseCurrentBlock();
     }
     // Get last residence hall. Can't parse parent before child with template class.
     $tpl->setCurrentBlock('halls');
     $tpl->setData(array('HALL_NAME' => $currHall));
     $tpl->parseCurrentBlock();
     return $tpl->get();
 }
예제 #2
0
 public function loadReasons($include_summary = false)
 {
     $db = new PHPWS_DB('checkin_reasons');
     $db->addWhere('checkin_rtos.staff_id', $this->id);
     $db->addWhere('id', 'checkin_rtos.reason_id');
     $db->addColumn('id');
     if ($include_summary) {
         $db->addColumn('summary');
         $db->setIndexBy('id');
     }
     $result = $db->select('col');
     if (!PHPWS_Error::logIfError($result)) {
         $this->_reasons =& $result;
     }
 }
예제 #3
0
 public static function getAllowedStates()
 {
     $db = new \PHPWS_DB('intern_state');
     $db->addWhere('active', 1);
     $db->addColumn('abbr');
     $db->addColumn('full_name');
     $db->setIndexBy('abbr');
     $db->addOrder('full_name ASC');
     $states = $db->select('col');
     if (empty($states)) {
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
         \NQ::close();
         PHPWS_Core::goBack();
     }
     return $states;
 }
예제 #4
0
파일: User.php 프로젝트: HaldunA/phpwebsite
 public static function getModList()
 {
     $db = new PHPWS_DB('search');
     $db->addColumn('module', null, null, false, true);
     $db->addColumn('modules.proper_name');
     $db->addGroupBy('modules.proper_name');
     $db->addWhere('search.module', 'modules.title');
     $db->setIndexBy('module');
     $result = $db->select('col');
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         $result = NULL;
     }
     $mod_list = array('all' => dgettext('search', 'All modules'));
     if (!empty($result)) {
         $mod_list = array_merge($mod_list, $result);
     }
     return $mod_list;
 }
예제 #5
0
 public static function getAllowedStates()
 {
     $db = new PHPWS_DB('intern_state');
     $db->addWhere('active', 1);
     $db->addColumn('abbr');
     $db->addColumn('full_name');
     $db->setIndexBy('abbr');
     // get backwards because we flip it
     $db->addOrder('full_name desc');
     $states = $db->select('col');
     if (empty($states)) {
         NQ::simple('intern', INTERN_ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
         NQ::close();
         PHPWS_Core::goBack();
     }
     $states[-1] = 'Select a state';
     $states = array_reverse($states, true);
     return $states;
 }
예제 #6
0
 public function getStaffList($as_object = false, $available_only = false, $active_only = false)
 {
     $db = new PHPWS_DB('checkin_staff');
     if ($available_only) {
         $db->addWhere('status', 1, '!=');
     }
     $db->addWhere('user_id', 'users.id');
     if ($active_only) {
         $db->addWhere('active', 1);
     }
     $db->addColumn('users.display_name');
     if ($as_object) {
         PHPWS_Core::initModClass('checkin', 'Staff.php');
         $db->addColumn('*');
         return $db->getObjects('Checkin_Staff');
     } else {
         $db->addColumn('id');
         $db->setIndexBy('id');
         return $db->select('col');
     }
 }
예제 #7
0
function properties_update(&$content, $currentVersion)
{
    switch ($currentVersion) {
        case version_compare($currentVersion, '1.1.0', '<'):
            $db = new PHPWS_DB('properties');
            $result = $db->addTableColumn('efficiency', 'smallint not null default 0');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add efficiency column';
                return false;
            }
            $content[] = '<pre>1.1.0 updates
---------------
+ Added efficiency option</pre>';
        case version_compare($currentVersion, '1.1.1', '<'):
            $db = new PHPWS_DB('prop_contacts');
            $result = $db->addTableColumn('company_url', 'VARCHAR( 255 ) NULL');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add company_url column';
                return false;
            }
            $content[] = '<pre>1.1.1 updates
---------------
+ Added company url
+ Property listing divided into tabs.</pre>';
        case version_compare($currentVersion, '1.2.0', '<'):
            $db = new PHPWS_DB('properties');
            $db->addWhere('pets_allowed', 1);
            $db->addColumn('id');
            $db->addColumn('pet_type');
            $db->setIndexBy('id');
            $cols = $db->select('col');
            if (!empty($cols)) {
                foreach ($cols as $id => $pets) {
                    if (empty($pets)) {
                        continue;
                    }
                    $db->reset();
                    $pets_array = null;
                    $pets_array = @unserialize($pets);
                    if (!is_array($pets_array)) {
                        continue;
                    } else {
                        $pets = implode(', ', $pets_array);
                    }
                    $db->addWhere('id', $id);
                    $db->addValue('pet_type', $pets);
                    $db->update();
                }
            }
            $db->reset();
            $result = $db->addTableColumn('pet_fee', 'int not null default 0');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add pet_fee column';
                return false;
            }
            $db->reset();
            $result = $db->addTableColumn('airconditioning', 'smallint not null default 0');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add airconditioning column';
                return false;
            }
            $db->reset();
            $result = $db->addTableColumn('heat_type', 'varchar(255) default null');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add heat_type column';
                return false;
            }
        case version_compare($currentVersion, '1.2.1', '<'):
            $content[] = '<pre>1.2.1 updates
---------------
- Improved look with Bootstrapping.</pre>';
        case version_compare($currentVersion, '1.2.2', '<'):
            $content[] = '<pre>1.2.2 updates
---------------
+ Added gas heat and fiber internet/tv.
</pre>';
        case version_compare($currentVersion, '1.3.0', '<'):
            $content[] = <<<EOF
<pre>1.3.0 updates
-----------------
+ Changed login box for IE users
+ Added ability to view properties by contact.
+ Contacts list compacted. Email links to contact name.
+ Fixed bad function call on error page.
+ Added error checks in case 1) the property does not exists or not active or
  2) the image files are not present.
+ Test for incactive properties preventing error.
+ Added Bootstrap styling and overhauled to work on mobile devices.
+ Last logged defaults to creation date.
+ Fixed Shared Bedroom and Bathroom settings on roommates page.
+ Fixed active/inactive buttons.
</pre>
EOF;
    }
    return true;
}
예제 #8
0
 public static function assignDefaultGroup(PHPWS_User $user)
 {
     $db = new PHPWS_DB('users_auth_scripts');
     $db->addColumn('default_group');
     $db->addColumn('id');
     $db->setIndexBy('id');
     $scripts = $db->select('col');
     $default_group = $scripts[$user->authorize];
     $group = new PHPWS_Group($default_group);
     if (!$group->id) {
         return false;
     }
     $group->addMember($user->_user_group);
     $group->save();
     return true;
 }
예제 #9
0
 public static function display()
 {
     PHPWS_Core::initModClass('intern', 'Term.php');
     PHPWS_Core::initModClass('intern', 'Department.php');
     PHPWS_Core::initModClass('intern', 'Major.php');
     PHPWS_Core::initModClass('intern', 'GradProgram.php');
     PHPWS_Core::initModClass('intern', 'Internship.php');
     PHPWS_Core::initModClass('intern', 'Agency.php');
     PHPWS_Core::initModClass('intern', 'Subject.php');
     PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php');
     // Set up search fields
     $form = new PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'intern');
     $form->addHidden('action', 'results');
     $form->useRowRepeat();
     $form->addText('name');
     $form->setLabel('name', "Name or Banner ID");
     $terms = Term::getTermsAssoc();
     //$thisTerm = Term::timeToTerm(time());
     $form->addSelect('term_select', $terms);
     $form->setLabel('term_select', 'Term');
     $form->setClass('term_select', 'form-control');
     //$form->setMatch('term_select', $thisTerm);
     // Deity can search for any department. Other users are restricted.
     if (Current_User::isDeity()) {
         $depts = Department::getDepartmentsAssoc();
     } else {
         $depts = Department::getDepartmentsAssocForUsername(Current_User::getUsername());
     }
     $form->addSelect('dept', $depts);
     $form->setLabel('dept', 'Department');
     //$form->setClass('', 'form-control');
     $form->setClass('dept', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $form->setMatch('dept', $keys[1]);
     }
     // Student level radio button
     javascript('jquery');
     javascriptMod('intern', 'majorSelector', array('form_id' => $form->id));
     $levels = array('-1' => 'Any Level', 'ugrad' => 'Undergraduate', 'grad' => 'Graduate');
     $form->addSelect('student_level', $levels);
     $form->setLabel('student_level', 'Level');
     $form->setClass('student_level', 'form-control');
     // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected)
     $levels = array('-1' => 'Choose student level first');
     $form->addDropBox('student_major', $levels);
     $form->setLabel('student_major', 'Major / Program');
     $form->addCssClass('student_major', 'form-control');
     // Undergrad major drop down
     if (isset($s)) {
         $majors = Major::getMajorsAssoc($s->ugrad_major);
     } else {
         $majors = Major::getMajorsAssoc();
     }
     $form->addSelect('ugrad_major', $majors);
     $form->setLabel('ugrad_major', 'Undergraduate Majors &amp; Certificate Programs');
     $form->setClass('ugrad_major', 'form-control');
     // Graduate major drop down
     if (isset($s)) {
         $progs = GradProgram::getGradProgsAssoc($s->grad_prog);
     } else {
         $progs = GradProgram::getGradProgsAssoc();
     }
     $form->addSelect('grad_prog', $progs);
     $form->setLabel('grad_prog', 'Graduate Majors &amp; Certificate Programs');
     $form->setClass('grad_prog', 'form-control');
     // Campus
     $campuses = array('main_campus' => 'Main Campus', 'distance_ed' => 'Distance Ed');
     $form->addRadioAssoc('campus', $campuses);
     /***************
      * Course Info *
      ***************/
     $subjects = Subject::getSubjects();
     $form->addSelect('course_subj', $subjects);
     $form->setLabel('course_subj', 'Subject');
     $form->setClass('course_subj', 'form-control');
     $form->addText('course_no');
     $form->setLabel('course_no', 'Course Number');
     $form->setSize('course_no', 6);
     $form->setMaxSize('course_no', 4);
     $form->setClass('course_no', 'form-control');
     $form->addText('course_sect');
     $form->setLabel('course_sect', 'Section');
     $form->setSize('course_sect', 6);
     $form->setMaxSize('course_sect', 4);
     $form->setClass('course_sect', 'form-control');
     // Internship types.
     $types = Internship::getTypesAssoc();
     $form->addRadioAssoc('type', $types);
     // Location
     $loc = array('domestic' => 'Domestic', 'internat' => 'International');
     $form->addRadioAssoc('loc', $loc);
     /* State search */
     $db = new PHPWS_DB('intern_state');
     $db->addWhere('active', 1);
     $db->addColumn('abbr');
     $db->addColumn('full_name');
     $db->setIndexBy('abbr');
     // get backwards because we flip it
     $db->addOrder('full_name desc');
     $states = $db->select('col');
     if (empty($states)) {
         NQ::simple('intern', INTERN_ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
         NQ::close();
         PHPWS_Core::goBack();
     }
     $states[-1] = 'Select state';
     $states = array_reverse($states, true);
     $form->addSelect('state', $states);
     $form->setLabel('state', 'State');
     $form->setClass('state', 'form-control');
     /* Province search */
     $form->addText('prov');
     $form->setLabel('prov', 'Province/Territory');
     $form->setClass('prov', 'form-control');
     // Workflow states
     $workflowStates = WorkflowStateFactory::getStatesAssoc();
     unset($workflowStates['CreationState']);
     // Remove this state, since it's not valid (internal only state for initial creation)
     $form->addCheckAssoc('workflow_state', $workflowStates);
     unset($_REQUEST['module']);
     unset($_REQUEST['action']);
     unset($_REQUEST['submit']);
     //test($_REQUEST,1);
     $form->plugIn($_REQUEST);
     $form->addSubmit('submit', 'Search');
     // Javascript...
     javascript('jquery');
     javascriptMod('intern', 'resetSearch');
     return PHPWS_Template::process($form->getTemplate(), 'intern', 'search.tpl');
 }
예제 #10
0
파일: Link.php 프로젝트: HaldunA/phpwebsite
 public function moveDown()
 {
     $db = new PHPWS_DB('controlpanel_link');
     $db->setIndexBy('link_order');
     $db->addWhere('tab', $this->tab);
     $db->addOrder('link_order');
     $allLinks = $db->getObjects('PHPWS_Panel_Link');
     $number_of_links = count($allLinks);
     $current_order = $this->getLinkOrder();
     if ($current_order == $number_of_links) {
         unset($allLinks[$current_order]);
         array_unshift($allLinks, $this);
     } else {
         $tempObj = $allLinks[$current_order + 1];
         $allLinks[$current_order] = $tempObj;
         $allLinks[$current_order + 1] = $this;
     }
     $count = 1;
     foreach ($allLinks as $link) {
         $link->setLinkOrder($count);
         $link->save();
         $count++;
     }
 }
예제 #11
0
 /**
  * Called from the three file type managers. Adds a file listing
  * to move files from one folder to another
  */
 public static function moveToForm(PHPWS_Form $form, $folder)
 {
     $db = new PHPWS_DB('folders');
     $db->addWhere('id', $folder->id, '!=');
     $db->addWhere('ftype', $folder->ftype);
     $db->addColumn('id');
     $db->addColumn('title');
     $db->setIndexBy('id');
     $folders = $db->select('col');
     if (!empty($folders)) {
         $folders = array(0 => '') + $folders;
         $form->addSelect('move_to_folder', $folders);
         $form->setLabel('move_to_folder', dgettext('filecabinet', 'Move to folder'));
     }
 }
예제 #12
0
 private function summaryReport()
 {
     javascript('datepicker');
     $form = new PHPWS_Form('report-date');
     $form->setMethod('get');
     $form->addHidden('module', 'checkin');
     $form->addHidden('aop', 'report');
     $form->addHidden('summary_report', 1);
     $form->addText('start_date', $_GET['start_date']);
     $form->setLabel('start_date', 'Start date');
     $form->setSize('start_date', 10);
     $form->setExtra('start_date', 'class="datepicker"');
     $form->addText('end_date', $_GET['end_date']);
     $form->setLabel('end_date', 'End date');
     $form->setSize('end_date', 10);
     $form->setExtra('end_date', 'class="datepicker"');
     if (!empty($_GET['visitor_name'])) {
         $name = trim(strip_tags($_GET['visitor_name']));
     } else {
         $name = null;
     }
     $form->addText('visitor_name', $name);
     $form->setLabel('visitor_name', 'Visitor name');
     $form->addSubmit(dgettext('checkin', 'Summary report'));
     $db = new PHPWS_DB('checkin_staff');
     $db->addColumn('checkin_staff.id');
     $db->addColumn('users.display_name');
     $db->addWhere('checkin_staff.user_id', 'users.id');
     $db->setIndexBy('id');
     $db->addOrder('users.display_name desc');
     $assigned = $db->select('col');
     $assigned[0] = dgettext('checkin', 'Show all');
     $assigned = array_reverse($assigned, true);
     $form->addSelect('assigned', $assigned);
     $form->setLabel('assigned', 'By staff');
     if (isset($_GET['assigned'])) {
         $staff_id = (int) $_GET['assigned'];
         $form->setMatch('assigned', $staff_id);
     } else {
         $staff_id = 0;
     }
     $tpl = $form->getTemplate();
     $start_date = strtotime($_GET['start_date']);
     $end_date = strtotime($_GET['end_date']);
     if (empty($start_date) || empty($end_date) || $start_date > $end_date) {
         $tpl['EMPTY'] = 'Please enter your date range again.';
     } else {
         $this->title = 'Visitors from ' . $_GET['start_date'] . ' to ' . $_GET['end_date'];
         $db = new PHPWS_DB('checkin_visitor');
         $db->addWhere('arrival_time', $start_date, '>=');
         $db->addWhere('arrival_time', $end_date, '<=');
         $db->addColumn('id');
         $db->addColumn('arrival_time');
         $db->addColumn('firstname');
         $db->addColumn('lastname');
         $db->addColumn('start_meeting');
         $db->addColumn('end_meeting');
         if ($staff_id) {
             $db->addWhere('assigned', $staff_id);
         }
         if (!empty($name)) {
             $name = strtolower($name);
             if (strlen($name) == 1) {
                 $db->addWhere('firstname', "{$name}%", 'like', 'and', 'name');
                 $db->addWhere('lastname', "{$name}%", 'like', 'or', 'name');
             } else {
                 $db->addWhere('firstname', "%{$name}%", 'like', 'and', 'name');
                 $db->addWhere('lastname', "%{$name}%", 'like', 'or', 'name');
             }
         }
         $result = $db->select();
         $total_visits = 0;
         $total_wait = 0;
         $total_meeting = 0;
         $total_days = 0;
         $incomplete_visits = 0;
         $current_day = null;
         foreach ($result as $visit) {
             extract($visit);
             $arrival_day = date('MdY', $arrival_time);
             if ($current_day != $arrival_day) {
                 $current_day = $arrival_day;
                 $total_days++;
             }
             $row = array();
             if (!$start_meeting || !$end_meeting) {
                 $incomplete_visits++;
                 continue;
             }
             $total_visits++;
             $twaited = $start_meeting - $arrival_time;
             $waited = Checkin::timeWaiting($twaited);
             if ($end_meeting) {
                 $tmeeting = $end_meeting - $start_meeting;
             }
             $meeting = Checkin::timeWaiting($tmeeting);
             $row['VISIT'] = $total_visits;
             $row['VISITOR'] = "{$firstname} {$lastname}";
             $row['DATE'] = date('g:ia m.d.Y', $arrival_time);
             $row['WAITED'] = $waited;
             $row['MEETING'] = $meeting;
             $tpl['rows'][] = $row;
             $total_wait += $twaited;
             $total_meeting += $tmeeting;
         }
         if ($total_visits) {
             $tpl['TOTAL_DAYS'] = $total_days;
             $tpl['TOTAL_VISITS'] = $total_visits;
             $tpl['AVG_VISITS'] = round($total_visits / $total_days, 1);
             $tpl['TOTAL_WAIT'] = Checkin::timeWaiting($total_wait);
             $tpl['TOTAL_MEETING'] = Checkin::timeWaiting($total_meeting);
             $tpl['AVG_WAIT'] = Checkin::timeWaiting(round($total_wait / $total_visits));
             $tpl['AVG_MEETING'] = Checkin::timeWaiting(round($total_meeting / $total_visits));
             $tpl['INCOMPLETE_MEETINGS'] = $incomplete_visits;
         } else {
             $tpl['EMPTY'] = 'No visits made in this date range.';
         }
     }
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'summary_report.tpl');
 }
예제 #13
0
 public static function allowDeny()
 {
     if (!PHPWS_Settings::get('access', 'allow_deny_enabled')) {
         $_SESSION['Access_Allow_Deny'] = true;
         return;
     }
     $address = Access::inflateIp($_SERVER['REMOTE_ADDR']);
     $allow_all = PHPWS_Settings::get('access', 'allow_all');
     $deny_all = PHPWS_Settings::get('access', 'deny_all');
     $db = new PHPWS_DB('access_allow_deny');
     $db->addWhere('active', 1);
     $db->addColumn('allow_or_deny');
     $db->addColumn('ip_address');
     $db->setIndexBy('allow_or_deny');
     $perms = $db->select('col');
     if (isset($perms[1]) && ($allow_all || !empty($perms[1]) && Access::comparePermissions($perms[1], $address))) {
         $_SESSION['Access_Allow_Deny'] = true;
     }
     if (isset($perms[0]) && ($deny_all || !empty($perms[0]) && Access::comparePermissions($perms[0], $address))) {
         $_SESSION['Access_Allow_Deny'] = false;
         return;
     }
     $_SESSION['Access_Allow_Deny'] = true;
     return;
 }
예제 #14
0
파일: Key.php 프로젝트: HaldunA/phpwebsite
 public function modulesInUse()
 {
     $db = new PHPWS_DB('phpws_key');
     $db->addColumn('module');
     $db->addColumn('modules.proper_name');
     $db->addWhere('module', 'modules.title');
     $db->addOrder('phpws_key.module');
     $db->setIndexBy('module');
     $db->setDistinct(true);
     return $db->select('col');
 }
예제 #15
0
 private function pageLinks(&$tpl)
 {
     $db = new PHPWS_DB('ps_page');
     $db->addWhere('deleted', 0);
     $db->addColumn('id');
     $db->addColumn('page_order');
     $db->setIndexBy('page_order');
     $db->addOrder('page_order asc');
     if ($this->parent_page) {
         $db->addWhere('id', $this->parent_page);
         $db->addWhere('parent_page', $this->parent_page, null, 'or');
     } else {
         $db->addWhere('parent_page', $this->id);
     }
     $pages = $db->select('col');
     if (PHPWS_Error::logIfError($pages) || empty($pages)) {
         return;
     }
     if (!$this->parent_page) {
         array_unshift($pages, $this->id);
     }
     if ($this->page_order) {
         $prev_page = $pages[$this->page_order - 1];
     } else {
         $prev_page = 0;
     }
     foreach ($pages as $page_no => $id) {
         if ($page_no == 0 && $prev_page) {
             $link = new PHPWS_Link('<span>&lt;&lt;</span>&#160;' . dgettext('pagesmith', 'Previous'), 'pagesmith', array('id' => $prev_page));
             $links[] = $link->get();
         }
         if ($id == $this->id) {
             $links[] = $page_no + 1;
             if (isset($pages[$page_no + 1])) {
                 $next_page = $pages[$page_no + 1];
             } else {
                 $next_page = null;
             }
         } else {
             $link = new PHPWS_Link($page_no + 1, 'pagesmith', array('id' => $id));
             $link->setRewrite();
             $links[] = $link->get();
         }
     }
     if ($next_page) {
         $link->setLabel(dgettext('pagesmith', 'Next') . '&#160;<span>&gt;&gt;</span>');
         $link->setValue('id', $next_page);
         $links[] = $link->get();
     }
     $tpl['PAGE_LINKS'] = implode('&#160;|&#160;', $links);
 }
예제 #16
0
 public function pinFolder($key_id)
 {
     $key = new Key($key_id);
     $this->cabinet->title = sprintf(dgettext('filecabinet', 'Pin folder to "%s"'), $key->title);
     $db = new PHPWS_DB('folders');
     $db->addWhere('public_folder', 1);
     $db->addColumn('title');
     $db->addColumn('id');
     $db->setIndexBy('id');
     $result = $db->select('col');
     if (empty($result)) {
         $this->cabinet->title = dgettext('filecabinet', 'Sorry..');
         $this->cabinet->content = dgettext('filecabinet', 'No public folders are available.');
         return;
     }
     $form = new PHPWS_Form('pinfolders');
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('aop', 'pin_folder');
     $form->addHidden('key_id', $key_id);
     $form->addSelect('folder_id', $result);
     $form->setLabel('folder_id', dgettext('filecabinet', 'Folder'));
     $form->addSubmit('submit', dgettext('filecabinet', 'Pin folder'));
     $tpl = $form->getTemplate();
     $tpl['CANCEL'] = javascript('close_window', array('value' => dgettext('filecabinet', 'Cancel')));
     $this->cabinet->content = PHPWS_Template::process($tpl, 'filecabinet', 'Forms/pin_folder.tpl');
 }
예제 #17
0
파일: Tab.php 프로젝트: HaldunA/phpwebsite
 public function moveDown()
 {
     $db = new PHPWS_DB('controlpanel_tab');
     $db->setIndexBy('tab_order');
     $db->addOrder('tab_order');
     $allTabs = $db->getObjects('PHPWS_Panel_Tab');
     $number_of_tabs = count($allTabs);
     $current_order = $this->getOrder();
     if ($current_order == $number_of_tabs) {
         unset($allTabs[$current_order]);
         array_unshift($allTabs, $this);
     } else {
         $tempObj = $allTabs[$current_order + 1];
         $allTabs[$current_order] = $tempObj;
         $allTabs[$current_order + 1] = $this;
     }
     $count = 1;
     foreach ($allTabs as $tab) {
         $tab->setOrder($count);
         $tab->save();
         $count++;
     }
 }
예제 #18
0
파일: User.php 프로젝트: HaldunA/phpwebsite
 public static function getContacts($active_only = false)
 {
     $db = new \PHPWS_DB('prop_contacts');
     $db->addOrder('company_name');
     $db->addColumn('id');
     $db->addColumn('company_name');
     $db->setIndexBy('id');
     if ($active_only) {
         $db->addWhere('active', 1);
     }
     $contacts = $db->select('col');
     if (\PHPWS_Error::isError($contacts)) {
         \PHPWS_Error::log($contacts);
         return array('0' => 'Error retrieving contacts');
     } else {
         return $contacts;
     }
 }
예제 #19
0
 public function getEvents($start_search, $end_search)
 {
     if (empty($start_search) || empty($end_search)) {
         return null;
     }
     $event_table = $this->getEventTable();
     if (!$event_table) {
         return null;
     }
     PHPWS_Core::initModClass('calendar', 'Event.php');
     $db = new PHPWS_DB($event_table);
     $db->addWhere('start_time', $start_search, '>=', null, 'start');
     $db->addWhere('start_time', $end_search, '<', 'AND', 'start');
     $db->addWhere('end_time', $end_search, '<=', null, 'end');
     $db->addWhere('end_time', $start_search, '>', 'AND', 'end');
     $db->addWhere('start_time', $start_search, '<', null, 'middle');
     $db->addWhere('end_time', $end_search, '>', 'AND', 'middle');
     $db->setGroupConj('end', 'OR');
     $db->setGroupConj('middle', 'OR');
     $db->addOrder('start_time');
     $db->addOrder('end_time desc');
     $db->setIndexBy('id');
     $result = $db->getObjects('Calendar_Event', $this);
     if (PHPWS_Error::logIfError($result)) {
         return null;
     }
     return $result;
 }
예제 #20
0
 public function getAllSlots($bare = false, $search = null)
 {
     PHPWS_Core::initModClass('signup', 'Slots.php');
     $db = new PHPWS_DB('signup_slots');
     $db->addOrder('s_order');
     $db->addWhere('sheet_id', $this->id);
     $db->setDistinct('true');
     // Prevents a slot from showing up multiple times in the results
     if ($search) {
         $db->addWhere('id', 'signup_peeps.slot_id');
         // Limits results to only Slots containing the search query
         $db->addWhere('signup_peeps.sheet_id', $this->id);
         $db->addWhere('signup_peeps.first_name', "{$search}%", 'like', 'and', 'search');
         $db->addWhere('signup_peeps.last_name', "{$search}%", 'like', 'or', 'search');
     }
     if ($bare) {
         $db->addColumn('id');
         $db->addColumn('title');
         $db->setIndexBy('id');
         return $db->select('col');
     } else {
         $result = $db->getObjects('Signup_Slot');
         if (empty($result) || PHPWS_Error::logIfError($result)) {
             return null;
         }
         $db = new PHPWS_DB('signup_peeps');
         $db->addColumn('id', null, null, true);
         foreach ($result as $slot) {
             $db->addWhere('slot_id', $slot->id);
             $db->addWhere('registered', 1);
             $sub = $db->select('one');
             $db->resetWhere();
             if (!PHPWS_Error::logIfError($sub)) {
                 $slot->_filled = $sub;
             }
         }
     }
     return $result;
 }
예제 #21
0
 public static function getAllLinks($alpha_order = false)
 {
     PHPWS_Core::initModClass('controlpanel', 'Link.php');
     $allLinks = null;
     // This session prevents the DB query and link
     // creation from being repeated.
     $idx = $alpha_order ? 'normal' : 'alpha';
     if (isset($_SESSION['CP_All_links'][$idx])) {
         return $_SESSION['CP_All_links'][$idx];
     }
     $DB = new PHPWS_DB('controlpanel_link');
     if ($alpha_order) {
         $DB->addOrder('label');
     } else {
         $DB->addOrder('label');
     }
     $DB->setIndexBy('id');
     $result = $DB->getObjects('PHPWS_Panel_Link');
     if (empty($result)) {
         return null;
     }
     foreach ($result as $link) {
         if (!$link->isRestricted() || Current_User::allow($link->itemname)) {
             $allLinks[$link->tab][] = $link;
         }
     }
     $_SESSION['CP_All_links'][$idx] = $allLinks;
     return $_SESSION['CP_All_links'][$idx];
 }
예제 #22
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');
 }
예제 #23
0
 public static function whatsnewBlock()
 {
     if (PHPWS_Settings::get('whatsnew', 'cache_timeout') > 0) {
         $cache_key = 'whatsnew_cache_key';
         $content = PHPWS_Cache::get($cache_key, PHPWS_Settings::get('whatsnew', 'cache_timeout'));
         if (!empty($content)) {
             return $content;
         }
     }
     $link = null;
     $summary = null;
     $date = null;
     $module_name = null;
     $exclude = unserialize(PHPWS_Settings::get('whatsnew', 'exclude'));
     $db = new PHPWS_DB('phpws_key');
     $db->addJoin('left', 'phpws_key', 'modules', 'module', 'title');
     $db->addWhere('active', 1);
     $db->addWhere('restricted', 0);
     if ($exclude) {
         foreach ($exclude as $module) {
             $db->addWhere('module', $module, '!=');
         }
     }
     $db->addOrder('update_date desc');
     $db->setLimit(PHPWS_Settings::get('whatsnew', 'qty_items'));
     $db->setIndexBy('id');
     $db->addColumn('phpws_key.url');
     $db->addColumn('phpws_key.title');
     $db->addColumn('phpws_key.summary');
     $db->addColumn('phpws_key.update_date');
     $db->addColumn('modules.title', null, 'module_title');
     $db->addColumn('modules.proper_name');
     //        $db->setTestMode();
     $result = $db->select();
     $tpl['TITLE'] = PHPWS_Text::parseOutput(PHPWS_Settings::get('whatsnew', 'title'));
     $tpl['TEXT'] = PHPWS_Text::parseOutput(PHPWS_Settings::get('whatsnew', 'text'));
     if (!PHPWS_Error::logIfError($result) && !empty($result)) {
         foreach ($result as $item) {
             $link = '<a href="' . $item['url'] . '">' . $item['title'] . '</a>';
             if (PHPWS_Settings::get('whatsnew', 'show_summaries')) {
                 $summary = PHPWS_Text::parseOutput($item['summary']);
             }
             if (PHPWS_Settings::get('whatsnew', 'show_dates')) {
                 $date = strftime(WHATSNEW_DATE_FORMAT, $item['update_date']);
             }
             if (PHPWS_Settings::get('whatsnew', 'show_source_modules')) {
                 $module_name = dgettext($item['module_title'], PHPWS_Text::parseOutput($item['proper_name']));
             }
             $tpl['new-items'][] = array('LINK' => $link, 'SUMMARY' => $summary, 'DATE' => $date, 'MODULE_NAME' => $module_name);
         }
     } else {
         $tpl['new-items'][] = array('LINK' => dgettext('whatsnew', 'Sorry, no results'));
     }
     $content = PHPWS_Template::process($tpl, 'whatsnew', 'block.tpl');
     if (PHPWS_Settings::get('whatsnew', 'cache_timeout') > 0 && !Current_User::isLogged() && !Current_User::allow('whatsnew')) {
         PHPWS_Cache::save($cache_key, $content);
     }
     return $content;
 }
예제 #24
0
function properties_update(&$content, $currentVersion)
{
    switch ($currentVersion) {
        case version_compare($currentVersion, '1.1.0', '<'):
            $db = new PHPWS_DB('properties');
            $result = $db->addTableColumn('efficiency', 'smallint not null default 0');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add efficiency column';
                return false;
            }
            $content[] = '<pre>1.1.0 updates
---------------
+ Added efficiency option</pre>';
        case version_compare($currentVersion, '1.1.1', '<'):
            $db = new PHPWS_DB('prop_contacts');
            $result = $db->addTableColumn('company_url', 'VARCHAR( 255 ) NULL');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add company_url column';
                return false;
            }
            $content[] = '<pre>1.1.1 updates
---------------
+ Added company url
+ Property listing divided into tabs.</pre>';
        case version_compare($currentVersion, '1.2.0', '<'):
            $db = new PHPWS_DB('properties');
            $db->addWhere('pets_allowed', 1);
            $db->addColumn('id');
            $db->addColumn('pet_type');
            $db->setIndexBy('id');
            $cols = $db->select('col');
            if (!empty($cols)) {
                foreach ($cols as $id => $pets) {
                    if (empty($pets)) {
                        continue;
                    }
                    $db->reset();
                    $pets_array = null;
                    $pets_array = @unserialize($pets);
                    if (!is_array($pets_array)) {
                        continue;
                    } else {
                        $pets = implode(', ', $pets_array);
                    }
                    $db->addWhere('id', $id);
                    $db->addValue('pet_type', $pets);
                    $db->update();
                }
            }
            $db->reset();
            $result = $db->addTableColumn('pet_fee', 'int not null default 0');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add pet_fee column';
                return false;
            }
            $db->reset();
            $result = $db->addTableColumn('airconditioning', 'smallint not null default 0');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add airconditioning column';
                return false;
            }
            $db->reset();
            $result = $db->addTableColumn('heat_type', 'varchar(255) default null');
            if (PHPWS_Error::isError($result)) {
                PHPWS_Error::log($result);
                $content[] = 'ERROR - could not add heat_type column';
                return false;
            }
        case version_compare($currentVersion, '1.2.1', '<'):
            $content[] = '<pre>1.2.1 updates
---------------
- Improved look with Bootstrapping.</pre>';
        case version_compare($currentVersion, '1.2.2', '<'):
            $content[] = '<pre>1.2.2 updates
---------------
+ Added gas heat and fiber internet/tv.
</pre>';
        case version_compare($currentVersion, '1.3.0', '<'):
            $content[] = <<<EOF
<pre>1.3.0 updates
-----------------
+ Changed login box for IE users
+ Added ability to view properties by contact.
+ Contacts list compacted. Email links to contact name.
+ Fixed bad function call on error page.
+ Added error checks in case 1) the property does not exists or not active or
  2) the image files are not present.
+ Test for incactive properties preventing error.
+ Added Bootstrap styling and overhauled to work on mobile devices.
+ Last logged defaults to creation date.
+ Fixed Shared Bedroom and Bathroom settings on roommates page.
+ Fixed active/inactive buttons.
</pre>
EOF;
        case version_compare($currentVersion, '1.4.0', '<'):
            if (!is_file(PHPWS_SOURCE_DIR . 'lib/vendor/autoload.php')) {
                $content[] = 'Composer is not installed. Be sure to run `composer install` in your installation\'s lib directory.';
                return false;
            }
            $db = \Database::getDB();
            $t1 = $db->addTable('prop_contacts');
            $dt = $t1->addDataType('private', 'smallint');
            $dt->setDefault(0);
            $dt->add();
            $dt2 = $t1->addDataType('approved', 'smallint');
            $dt2->setDefault(1);
            $dt2->add();
            $t1->addFieldConditional('company_name', 'private%', 'like');
            $t1->addValue('private', 1);
            $db->update();
            $old = $t1->getDataType('company_name');
            $new = clone $old;
            $new->setIsNull(true);
            $t1->alter($old, $new);
            $content[] = <<<EOF
<pre>1.4.0 updates
-----------------
+ Added Private Renter designation.
+ Added new manager signup.
</pre>
EOF;
        case version_compare($currentVersion, '1.4.1', '<'):
            $content[] = <<<EOF
<pre>1.4.1 updates
-----------------
+ New user signup requires all email settings to be set.
+ Invalid and duplicate email addresses are now checked on signup.
</pre>
EOF;
        case version_compare($currentVersion, '1.4.2', '<'):
            $content[] = <<<EOF
<pre>1.4.2 updates
-----------------
+ Fixed: New managers could log in before approved.
</pre>
EOF;
    }
    return true;
}
예제 #25
0
/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function users_update(&$content, $currentVersion)
{
    $home_dir = PHPWS_Boost::getHomeDir();
    switch ($currentVersion) {
        case version_compare($currentVersion, '2.2.0', '<'):
            $content[] = 'This package does not update versions under 2.2.0';
            return false;
        case version_compare($currentVersion, '2.2.1', '<'):
            $content[] = '+ Fixed a bug causing conflicts between user and group permissions.';
        case version_compare($currentVersion, '2.2.2', '<'):
            $content[] = '+ Set username to the same character size in both users table and user_authorization.';
            $content[] = '+ Fixed typo causing branch installation failure on Postgresql.';
        case version_compare($currentVersion, '2.3.0', '<'):
            $content[] = '<pre>
2.3.0 changes
------------------------
+ Added translate function calls in classes and my_page.php
+ my_page hides translation option if language defines disable selection
+ Added a unrestricted only parameter to Current_User\'s allow and
  authorize functions
+ Dropped references from some constructors
+ Added error check to setPermissions function: won\'t accept empty
  group id
+ Changed id default to zero.
+ Removed unneeded function parameter on getGroups
</pre>
';
        case version_compare($currentVersion, '2.3.1', '<'):
            $content[] = '<pre>';
            $files = array('templates/my_page/user_setting.tpl');
            userUpdateFiles($files, $content);
            $content[] = '
2.3.1 changes
------------------------
+ Added ability for user to set editor preferences
</pre>
';
        case version_compare($currentVersion, '2.3.2', '<'):
            $content[] = '<pre>2.3.2 changes';
            $files = array('img/users.png', 'templates/user_main.tpl');
            userUpdateFiles($files, $content);
            $content[] = '+ Added error check to login.
+ Changed user control panel icon.
+ Fixed template typo that broke IE login.
+ Removed fake French translation (delete mod/users/locale/fr_FR/ directory
+ Permissions are now ordered alphabetically.
+ isUser will now always return false if passed a zero id.
+ Added new function requireLogin that forwards a user to the login
  screen
</pre>';
        case version_compare($currentVersion, '2.4.0', '<'):
            if (!PHPWS_DB::isTable('users_pw_reset')) {
                $new_table = 'CREATE TABLE users_pw_reset (
user_id INT NOT NULL default 0,
authhash CHAR( 32 ) NOT NULL default 0,
timeout INT NOT NULL default 0,
);';
                if (!PHPWS_DB::import($new_table)) {
                    $content[] = 'Unable to create users_pw_reset table.';
                    return false;
                } else {
                    $content[] = 'Created new table: users_pw_reset';
                }
            }
            $files = array('templates/forms/reset_password.tpl', 'templates/forms/forgot.tpl', 'conf/config.php', 'templates/usermenus/top.tpl', 'templates/forms/settings.tpl', 'templates/my_page/user_setting.tpl');
            $content[] = '<pre>';
            userUpdatefiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_0.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '2.4.1', '<'):
            $content[] = '<pre>';
            $files = array('conf/languages.php');
            userUpdateFiles($files, $content);
            $content[] = '
2.4.1 changes
------------------------
+ Default item id on permission check functions is now zero instead of
  null. This will make checking permissions a little easier on new items.
+ Bug #1690657 - Changed group select js property to onclick instead
  of onchange. Thanks singletrack.
+ Changed the language abbreviation for Danish
</pre>
';
        case version_compare($currentVersion, '2.4.2', '<'):
            $content[] = '<pre>';
            $files = array('templates/usermenus/Default.tpl');
            userUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_2.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '2.4.3', '<'):
            $content[] = '<pre>';
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_3.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '2.4.4', '<'):
            $content[] = '<pre>';
            $source_dir = PHPWS_SOURCE_DIR . 'mod/users/javascript/';
            $dest_dir = $home_dir . 'javascript/modules/users/';
            if (PHPWS_File::copy_directory($source_dir, $dest_dir, true)) {
                $content[] = "--- Successfully copied {$source_dir} to {$dest_dir}";
            } else {
                $content[] = "--- Could not copy {$source_dir} to {$dest_dir}";
            }
            $files = array('conf/error.php', 'templates/forms/permissions.tpl', 'templates/forms/permission_pop.tpl');
            userUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_4.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '2.4.5', '<'):
            $content[] = '<pre>';
            $files = array('conf/error.php', 'conf/languages.php', 'templates/forms/settings.tpl', 'templates/manager/groups.tpl');
            userUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_4_5.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '2.4.6', '<'):
            $content[] = '<pre>';
            $files = array('templates/forms/forgot.tpl');
            userUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = '
2.4.6 changes
-------------------
+ Added error check to permission menu.
+ Error for missing user groups now reports user id.
+ Forgot password will work if CAPTCHA is disabled.
+ Using new savePermissions function instead of save.
+ Current_User was calling giveItemPermissions incorrectly.';
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '2.4.7', '<'):
            $content[] = '<pre>
2.4.7 changes
-------------------
+ Removed global authorization from change password check since it is not
  written yet.
</pre>';
        case version_compare($currentVersion, '2.4.9', '<'):
            $content[] = '<pre>';
            if (PHPWS_Core::isBranch() || PHPWS_Boost::inBranch()) {
                $user_db = new PHPWS_DB('users');
                $user_db->addWhere('deity', 1);
                $user_db->addColumn('id');
                $user_db->addColumn('username');
                $user_db->setIndexBy('id');
                $user_ids = $user_db->select('col');
                if (!empty($user_ids) && !PHPWS_Error::logIfError($user_ids)) {
                    $group_db = new PHPWS_DB('users_groups');
                    foreach ($user_ids as $id => $username) {
                        $group_db->addWhere('user_id', $id);
                        $result = $group_db->select('row');
                        if (!$result) {
                            $group_db->reset();
                            $group_db->addValue('active', 1);
                            $group_db->addValue('name', $username);
                            $group_db->addValue('user_id', $id);
                            if (!PHPWS_Error::logIfError($group_db->insert())) {
                                $content[] = '--- Created missing group for user: '******'2.4.9 changes
-----------------
+ Raised sql character limit in default username, display_name, and
  group name installs.
+ Fixed bug with forbidden usernames
+ Added a function to group to remove its permissions upon deletion.
+ Bookmark won\'t return a user to a authkey page if their session dies.
+ Fixed bug #1850815 : unknown function itemIsAllowed in Permission.php
+ My Pages are unregistered on module removal.
+ My Page tab stays fixed.
</pre>';
        case version_compare($currentVersion, '2.5.0', '<'):
            $content[] = '<pre>';
            $files = array('templates/forms/memberlist.tpl', 'templates/forms/userForm.tpl', 'javascript/generate/head.js', 'templates/manager/groups.tpl', 'templates/manager/users.tpl');
            userUpdateFiles($files, $content);
            $content[] = '2.5.0 changes
-------------------
+ Members\' names alphabetized
+ New user email notification added.
+ Fixed member listing  dropping names past 10.
+ Added random password generator on user edit form.
+ Removed reference from Action.php causing php notice.
+ Changed redundant static method call in Permission.
+ Added dash to allowed display name characters.
+ Added \\pL to display name characters.
+ Users will now query modules should a user get deleted.
+ Added an error check to Permissions.
+ Users will now look for remove_user.php in all modules\' inc/
  directory in order to run the remove_user function.
+ Using pager\'s addSortHeaders in user and group listing
+ Added display name to pager search.
</pre>';
        case version_compare($currentVersion, '2.6.0', '<'):
            $content[] = '<pre>';
            Users_Permission::registerPermissions('users', $content);
            $db = new PHPWS_DB('users_auth_scripts');
            $db->addWhere('filename', 'local.php');
            $db->addColumn('id');
            $auth_id = $db->select('one');
            PHPWS_Settings::set('users', 'local_script', $auth_id);
            PHPWS_Settings::save('users');
            $files = array('conf/languages.php', 'templates/my_page/user_setting.tpl', 'templates/usermenus/css.tpl', 'img/permission.png', 'templates/forms/userForm.tpl');
            userUpdateFiles($files, $content);
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/users/boost/changes/2_6_0.txt');
            }
            $content[] = '</pre>';
        case version_compare($currentVersion, '2.6.1', '<'):
            $content[] = '<pre>2.6.1 changes
------------------
+ requireLogin now reroutes dependant on the user authorization
+ If the user\'s group is missing when they are updated, a new one is
  properly created. Prior to the fix, a new group was created without an
  assigned user id.
+ Added error message to my page if update goes bad.
</pre>';
        case version_compare($currentVersion, '2.6.2', '<'):
            $content[] = '<pre>';
            $files = array('templates/forms/settings.tpl');
            userUpdateFiles($files, $content);
            $content[] = '2.6.2 changes
------------------
+ Moved error file to inc/
+ Blank passwords forbidden.
+ Error check added to cosign authorization.
+ php fiveasized the classes.
+ Added some needed error logging to user creation problems
+ Added ability for default user groups to be set for admin created
  and newly joined users.
+ Fixed testing on addMembers. Previous code was nonsensical.
+ _user_group id gets set upon a user object save.
</pre>';
        case version_compare($currentVersion, '2.6.3', '<'):
            $content[] = '<pre>';
            $files = array('img/deity.gif', 'img/delete.png', 'img/edit.png', 'img/man.gif', 'img/key.png', 'img/members.png', 'templates/forms/authorization.tpl', 'templates/forms/settings.tpl', 'templates/manager/users.tpl');
            userUpdateFiles($files, $content);
            $db = new PHPWS_DB('users_auth_scripts');
            PHPWS_Error::logIfError($db->addTableColumn('default_group', 'int not null default 0'));
            $content[] = '2.6.3 changes
------------------
+ Added icons for admin options under manage users and groups
+ Disabled active link in groups listing
+ Authorization scripts now have default group assignments. New
  members will assigned to a group based on their authorization
  method.
+ Removed default group by user or admin from settings.
+ Added ability to view users by whether or not they are in a
  particular group.
+ Added pager caching to group listing
+ Display name may now not be the same as another user\'s username
+ Extended user name error to include display name
+ Added empty password check to ldap script
</pre>';
        case version_compare($currentVersion, '2.6.4', '<'):
            $db = new PHPWS_DB('users_auth_scripts');
            PHPWS_Error::logIfError($db->addTableColumn('default_group', 'int not null default 0'));
            $content[] = '<pre>2.6.4 changes
-------------------------
+ Added missing column to install.sql</pre>';
        case version_compare($currentVersion, '2.6.5', '<'):
            $content[] = '<pre>';
            userUpdateFiles(array('conf/languages.php'), $content);
            $content[] = '2.6.5 changes
-------------------------
+ Added missing column to install.sql</pre>';
        case version_compare($currentVersion, '2.6.6', '<'):
            $content[] = '<pre>';
            userUpdateFiles(array('templates/forms/userForm.tpl'), $content);
            $content[] = '2.6.6 changes
        -----------------------
+ Graceful recovery from broken authentication scripts.
+ Authorization script made deity only
+ Fixed default groups on external authentication
+ Deleted auth scripts will update users under it to use local instead.
+ The user constructor was trying to load the authorization script on
  failed users. Thanks Verdon.</pre>';
        case version_compare($currentVersion, '2.7.0', '<'):
            $content[] = '<pre>2.7.0 changes
-------------------------
+ Usernames and passwords can not be changed on non local users
+ Added switch to settings to prevent admins from making new users
+ Site admin can be set by non-deities again
+ Fixed bug with users able to change password on alternate auth.
+ Fixed some bugs with user creation and editing with alternate authentication.
+ Hiding permissions and members in create group form
+ Icon class implemented.
+ Strict PHP 5 changes made.
</pre>';
        case version_compare($currentVersion, '2.7.1', '<'):
            $content[] = '<pre>2.7.1 changes
-------------------------
+ Improved cosign script
+ Fixed errors getting dropped without logging.
</pre>';
        case version_compare($currentVersion, '2.7.2', '<'):
            $content[] = '<pre>2.7.2 changes
-------------------------
+ Fixed multiple group member bug.
+ Cleaned up cosign authentication.
+ Current_User requireLogin to use login_link instead of login_url
+ New User form now properly respects the "settings" permission for showing
  user authentication script option.
+ User constuction allow username parameter.
+ Trim whitespace from user email addresses. Don\'t modify the member variable
  unless all the sanity checks passed.
</pre>';
        case version_compare($currentVersion, '2.7.3', '<'):
            PHPWS_Core::initModClass('users', 'Action.php');
            User_Action::checkPermissionTables();
            $content[] = '<pre>2.7.3 changes
------------------------
+ Update permissions
</pre>';
        case version_compare($currentVersion, '2.7.4', '<'):
            $content[] = '<pre>2.7.4 changes
------------------------
+ Fixed 500 error on My Page
</pre>';
        case version_compare($currentVersion, '2.7.5', '<'):
            $content[] = '<pre>2.7.5 changes
------------------------
+ Loosened group name restrictions
+ User edit page shows group membership
</pre>';
        case version_compare($currentVersion, '2.7.6', '<'):
            $content[] = '<pre>2.7.6 changes
------------------------
+ Updated icons to Font Awesome
+ Email addresses may now be used as user names.
+ Static method call fixed.
+ Added exception error for missing authorization file.
+ My Page no longer is using tabs as other modules use of My Page have been removed.
+ css.tpl template rewritten. Login now works closer with authentication script.
    - drop down no longer contains Home or Control Panel. Account link added - takes
        user to their account page to change their password.
</pre>';
        case version_compare($currentVersion, '2.8.0', '<'):
            $content[] = <<<EOF
<pre>2.8.0 changes
-----------------
+ Added suggested bootstrap classes from TRF
+ Removed call to nonexistent method.
+ Moved icons to left and set admin-icons class to column.
+ Added FA icon here for mini admin
+ Changed to ensure users_auth_scripts table was created properly
+ Session timeouts are now tracked. Warning to user given before failure.
</pre>
EOF;
        case version_compare($currentVersion, '2.8.1', '<'):
            \PHPWS_Settings::set('users', 'session_warning', 0);
            \PHPWS_Settings::save('users');
            $content[] = <<<EOF
<pre>2.8.1 changes
-----------------
+ Changing default on user session to false. If you want it enabled, do so in settings.
</pre>
EOF;
        case version_compare($currentVersion, '2.8.2', '<'):
            $content[] = <<<EOF
<pre>2.8.2 changes
-----------------
+ Bug Fix: Unstyled permission pop up.
</pre>
EOF;
    }
    // End of switch statement
    return TRUE;
}
예제 #26
0
파일: Box.php 프로젝트: HaldunA/phpwebsite
 /**
  * Moves a box to a new location
  */
 public function move($dest)
 {
     if ($dest != 'move_box_up' && $dest != 'move_box_down' && $dest != 'move_box_top' && $dest != 'move_box_bottom' && $dest != 'restore') {
         $themeVars = $_SESSION['Layout_Settings']->getAllowedVariables();
         if (!in_array($dest, $themeVars)) {
             return PHPWS_Error::get(LAYOUT_BAD_THEME_VAR, 'layout', 'Layout_Box::move', $dest);
         }
         $themeVar = $this->theme_var;
         $this->setThemeVar($dest);
         $this->setBoxOrder(NULL);
         $this->save();
         $this->reorderBoxes($this->theme, $themeVar);
         return;
     }
     $db = new PHPWS_DB('layout_box');
     $db->addWhere('id', $this->id, '!=');
     $db->addWhere('theme', $this->theme);
     $db->addWhere('theme_var', $this->theme_var);
     $db->addOrder('box_order');
     $db->setIndexBy('box_order');
     $boxes = $db->getObjects('Layout_Box');
     if (empty($boxes)) {
         return NULL;
     }
     if (PHPWS_Error::isError($boxes)) {
         PHPWS_Error::log($boxes);
         return NULL;
     }
     switch ($dest) {
         case 'restore':
             $this->kill();
             $this->reorderBoxes($this->theme, $this->theme_var);
             Layout::resetBoxes();
             return;
             break;
         case 'move_box_up':
             if ($this->box_order == 1) {
                 $this->move('move_box_bottom');
                 return;
             } else {
                 $old_box =& $boxes[$this->box_order - 1];
                 $old_box->box_order++;
                 $this->box_order--;
                 if (!PHPWS_Error::logIfError($old_box->save())) {
                     PHPWS_Error::logIfError($this->save());
                 }
                 return;
             }
             break;
         case 'move_box_down':
             if ($this->box_order == count($boxes) + 1) {
                 $this->move('move_box_top');
                 return;
             } else {
                 $old_box =& $boxes[$this->box_order + 1];
                 $old_box->box_order--;
                 $this->box_order++;
                 if (!PHPWS_Error::logIfError($old_box->save())) {
                     PHPWS_Error::logIfError($this->save());
                 }
                 return;
             }
             break;
         case 'move_box_top':
             $this->box_order = 1;
             $this->save();
             $count = 2;
             break;
         case 'move_box_bottom':
             $this->box_order = count($boxes) + 1;
             $this->save();
             $count = 1;
             break;
     }
     foreach ($boxes as $box) {
         $box->box_order = $count;
         $box->save();
         $count++;
     }
 }
예제 #27
0
 public function reorderLinks()
 {
     if (!$this->id) {
         return false;
     }
     $db = new PHPWS_DB('menu_links');
     $db->addWhere('menu_id', $this->id);
     $db->addColumn('id');
     $db->addColumn('parent');
     $db->addColumn('link_order');
     $db->addOrder('link_order');
     $db->setIndexBy('parent');
     $result = $db->select();
     if (empty($result)) {
         return;
     }
     foreach ($result as $parent_id => $links) {
         if (empty($links)) {
             continue;
         }
         $count = 1;
         if (isset($links[0])) {
             foreach ($links as $link) {
                 $db->reset();
                 $db->addWhere('id', $link['id']);
                 $db->addValue('link_order', $count);
                 PHPWS_Error::logIfError($db->update());
                 $count++;
             }
         } else {
             $db->reset();
             $db->addWhere('id', $links['id']);
             $db->addValue('link_order', $count);
             PHPWS_Error::logIfError($db->update());
         }
     }
     return true;
 }