function form($object)
 {
     global $db;
     $tag_collections = $db->selectObjects("tag_collections");
     foreach ($tag_collections as $tag_collections => $collection) {
         $tc_list[$collection->id] = $collection->name;
     }
     //eDebug($all_calendars);
     $form = new form();
     if (!isset($object->id)) {
         // $object->enable_categories = 0;
         $object->enable_feedback = 0;
         $object->reminder_notify = serialize(array());
         $object->email_title_reminder = "Calendar Reminder";
         $object->email_from_reminder = "Calendar Manager";
         $object->email_address_reminder = "calendar@" . HOSTNAME;
         $object->email_reply_reminder = "calendar@" . HOSTNAME;
         $object->email_showdetail = 0;
         $object->email_signature = "--\nThanks, Webmaster";
         $object->aggregate = array();
         $object->enable_rss = false;
         $object->enable_ical = true;
         $object->feed_title = "";
         $object->feed_desc = "";
         $object->rss_limit = 365;
         $object->rss_cachetime = 60;
         // $object->enable_tags = false;
         // $object->collections = array();
         // $object->group_by_tags = false;
         // $object->show_tags = array();
     } else {
         $form->meta('id', $object->id);
         // $cols = unserialize($object->collections);
         // $object->collections = array();
         // $available_tags = array();
         // if (!empty($cols)) {
         // foreach ($cols as $col_id) {
         // $collection = $db->selectObject('tag_collections', 'id='.$col_id);
         // $object->collections[$collection->id] = $collection->name;
         // //while we're here we will get the list of available tags.
         // $tmp_tags = $db->selectObjects('tags', 'collection_id='.$col_id);
         // foreach ($tmp_tags as $tag) {
         // $available_tags[$tag->id] = $tag->name;
         // }
         // }
         // }
         // //Get the tags the user chose to show in the group by views
         // $stags = unserialize($object->show_tags);
         // $object->show_tags = array();
         // //			if (is_array($stags)) {
         // if (!empty($stags)) {
         // foreach ($stags as $stag_id) {
         // $show_tag = $db->selectObject('tags', 'id='.$stag_id);
         // $object->show_tags[$show_tag->id] = $show_tag->name;
         // }
         // }
     }
     // setup the listbuilder arrays for calendar aggregation.
     $loc = unserialize($object->location_data);
     $calendars = expModules::listInstalledControllers('calendarmodule');
     $saved_aggregates = empty($object->aggregate) ? array() : unserialize($object->aggregate);
     $all_calendars = array();
     $selected_calendars = array();
     foreach ($calendars as $src => $cal) {
         $calendar_name = (empty($cal->title) ? 'Untitled' : $cal->title) . ' on page ' . $cal->section;
         if ($src != $loc->src) {
             if (in_array($src, $saved_aggregates)) {
                 $selected_calendars[$src] = $calendar_name;
             } else {
                 $all_calendars[$src] = $calendar_name;
             }
         }
     }
     // setup the config form
     $form->register(null, '', new htmlcontrol('<h3>' . gt('General Configuration') . '</h3><hr size="1" />'));
     // $form->register('enable_categories',gt('Enable Categories'),new checkboxcontrol($object->enable_categories,true));
     $form->register('enable_feedback', gt('Enable Feedback'), new checkboxcontrol($object->enable_feedback, true));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('Events Reminder Email') . '</h3><hr size="1" />'));
     // Get original style user lists
     // $selected_users = array();
     // foreach(unserialize($object->reminder_notify) as $i) {
     // $selected_users[$i] = $db->selectValue('user', 'firstname', 'id='.$i) . ' ' . $db->selectValue('user', 'lastname', 'id='.$i) . ' (' . $db->selectValue('user', 'username', 'id='.$i) . ')';
     // }
     // $userlist = array();
     // $list = user::getAllUsers();
     // foreach ($list as $i) {
     // if(!array_key_exists($i->id, $selected_users)) {
     // $userlist[$i->id] = $i->firstname . ' ' . $i->lastname . ' (' . $i->username . ')';
     // }
     // }
     // $form->register('reminder_notify',gt('Who should be reminded of events?'),new listbuildercontrol($selected_users, $userlist));
     // Get User list
     $defaults = array();
     $userlist = array();
     $users = user::getAllUsers();
     foreach ($db->selectObjects('calendar_reminder_address', 'calendar_id=' . $object->id . ' and user_id != 0') as $address) {
         $locuser = user::getUserById($address->user_id);
         $defaults[$locuser->id] = $locuser->firstname . ' ' . $locuser->lastname . ' (' . $locuser->username . ')';
     }
     foreach ($users as $locuser) {
         if (!array_key_exists($locuser->id, $defaults)) {
             $userlist[$locuser->id] = $locuser->firstname . ' ' . $locuser->lastname . ' (' . $locuser->username . ')';
         }
     }
     $form->register('users', gt('Users'), new listbuildercontrol($defaults, $userlist));
     // Get Group list
     $defaults = array();
     $grouplist = array();
     $groups = group::getAllGroups();
     if ($groups != null) {
         foreach ($db->selectObjects('calendar_reminder_address', 'calendar_id=' . $object->id . ' and group_id != 0') as $address) {
             $group = group::getGroupById($address->group_id);
             $defaults[$group->id] = $group->name;
         }
         foreach ($groups as $group) {
             if (!array_key_exists($group->id, $defaults)) {
                 $grouplist[$group->id] = $group->name;
             }
         }
         $form->register('groups', gt('Groups'), new listbuildercontrol($defaults, $grouplist));
     }
     // Get Freeform list
     $defaults = array();
     foreach ($db->selectObjects('calendar_reminder_address', 'calendar_id=' . $object->id . " and email != ''") as $address) {
         $defaults[$address->email] = $address->email;
     }
     $form->register('addresses', gt('Other Addresses'), new listbuildercontrol($defaults, null));
     $form->register('email_title_reminder', gt('Message Subject Prefix'), new textcontrol($object->email_title_reminder, 45));
     $form->register('email_from_reminder', gt('From (Display)'), new textcontrol($object->email_from_reminder, 45));
     $form->register('email_address_reminder', gt('From (Email)'), new textcontrol($object->email_address_reminder, 45));
     $form->register('email_reply_reminder', gt('Reply-to'), new textcontrol($object->email_reply_reminder, 45));
     $form->register('email_showdetail', gt('Show detail in message?'), new checkboxcontrol($object->email_showdetail));
     $form->register('email_signature', gt('Email Signature'), new texteditorcontrol($object->email_signature, 5, 30));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('Merge Calendars') . '</h3><hr size="1" />'));
     $form->register('aggregate', gt('Pull Events from These Other Calendars'), new listbuildercontrol($selected_calendars, $all_calendars));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('RSS/iCalendar Configuration') . '</h3><hr size="1" />'));
     $form->register('enable_rss', gt('Enable RSS'), new checkboxcontrol($object->enable_rss));
     $form->register('enable_ical', gt('Enable iCalendar'), new checkboxcontrol($object->enable_ical));
     $form->register('feed_title', gt('Title for this RSS feed'), new textcontrol($object->feed_title, 35, false, 75));
     $form->register('feed_desc', gt('Description for this RSS feed'), new texteditorcontrol($object->feed_desc));
     $form->register('rss_cachetime', gt('Recommended RSS/iCal feed update interval in minutes (1440 = 1 day)'), new textcontrol($object->rss_cachetime));
     $form->register('rss_limit', gt('Maximum days of RSS/iCal items to publish (0 = all)'), new textcontrol($object->rss_limit));
     // $form->register(null,'',new htmlcontrol('<h3>'.gt('Tagging').'</h3><hr size="1" />'));
     // $form->register('enable_tags',gt('Enable Tags'), new checkboxcontrol($object->enable_tags));
     // $form->register('collections',gt('Tag Collections'),new listbuildercontrol($object->collections,$tc_list));
     // $form->register('group_by_tags',gt('Filter events by tags'), new checkboxcontrol($object->group_by_tags));
     // $form->register(null,'',new htmlcontrol(gt('Tags to show')));
     // $form->register('show_tags','',new listbuildercontrol($object->show_tags,$available_tags));
     $form->register('submit', '', new buttongroupcontrol(gt('Save'), '', gt('Cancel')));
     return $form;
 }
Beispiel #2
0
             $from_name = $user->firstname . " " . $user->lastname . " (" . $user->username . ")";
         } else {
             $db_data->user_id = 0;
         }
         $db_data->timestamp = time();
     }
     $db->insertObject($db_data, 'formbuilder_' . $f->table_name);
 }
 //Email stuff here...
 //Don't send email if this is an edit.
 if ($f->is_email == 1 && !isset($_POST['data_id'])) {
     //Building Email List...
     $emaillist = array();
     foreach ($db->selectObjects("formbuilder_address", "form_id=" . $f->id) as $address) {
         if ($address->group_id != 0) {
             foreach (group::getUsersInGroup(group::getGroupById($address->group_id)) as $locUser) {
                 if ($locUser->email != '') {
                     $emaillist[] = $locUser->email;
                 }
             }
         } else {
             if ($address->user_id != 0) {
                 $locUser = user::getUserById($address->user_id);
                 if ($locUser->email != '') {
                     $emaillist[] = $locUser->email;
                 }
             } else {
                 if ($address->email != '') {
                     $emaillist[] = $address->email;
                 }
             }
Beispiel #3
0
 static function checkForSectionalAdmins($id)
 {
     global $db;
     $section = $db->selectObject('section', 'id=' . $id);
     $branch = navigationmodule::levelTemplate($id, 0);
     array_unshift($branch, $section);
     $allusers = array();
     $allgroups = array();
     while ($section->parent > 0) {
         $ploc = expCore::makeLocation('navigationmodule', null, $section);
         $allusers = array_merge($allusers, $db->selectColumn('userpermission', 'uid', "permission='manage' AND module='navigationmodule' AND internal=" . $section->parent));
         $allgroups = array_merge($allgroups, $db->selectColumn('grouppermission', 'gid', "permission='manage' AND module='navigationmodule' AND internal=" . $section->parent));
         $section = $db->selectObject('section', 'id=' . $section->parent);
     }
     foreach ($branch as $section) {
         $sloc = expCore::makeLocation('navigationmodule', null, $section->id);
         // remove any manage permissions for this page and it's children
         // $db->delete('userpermission', "module='navigationmodule' AND internal=".$section->id);
         // $db->delete('grouppermission', "module='navigationmodule' AND internal=".$section->id);
         foreach ($allusers as $uid) {
             $u = user::getUserById($uid);
             expPermissions::grant($u, 'manage', $sloc);
         }
         foreach ($allgroups as $gid) {
             $g = group::getGroupById($gid);
             expPermissions::grantGroup($g, 'manage', $sloc);
         }
     }
 }
 static function form($object)
 {
     global $db;
     //global $user;
     $form = new form();
     if (!isset($object->id)) {
         $object->name = '';
         $object->description = '';
         $object->is_email = 0;
         $object->is_saved = 1;
         $object->response = gt('Your form has been submitted');
         $object->resetbtn = gt('Reset');
         $object->submitbtn = gt('Submit');
         $object->subject = gt('Submitted form from site');
     } else {
         $form->meta('id', $object->id);
     }
     $form->register('name', gt('Name'), new textcontrol($object->name));
     $form->register('description', gt('Description'), new texteditorcontrol($object->description));
     $form->register('response', gt('Response'), new htmleditorcontrol($object->response));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('Button Settings') . '</h3><hr size="1" />'));
     $form->register('submitbtn', gt('Submit Button Text'), new textcontrol($object->submitbtn));
     $form->register('resetbtn', gt('Reset Button Text'), new textcontrol($object->resetbtn));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('Email Settings') . '</h3><hr size="1" />'));
     $form->register('is_email', gt('Email Form'), new checkboxcontrol($object->is_email, false));
     // Get User list
     $userlist = array();
     $defaults = array();
     $users = user::getAllUsers();
     foreach ($db->selectObjects('formbuilder_address', 'form_id=' . $object->id . ' and user_id != 0') as $address) {
         $locuser = user::getUserById($address->user_id);
         $defaults[$locuser->id] = $locuser->firstname . ' ' . $locuser->lastname . ' (' . $locuser->username . ')';
     }
     foreach ($users as $locuser) {
         if (!array_key_exists($locuser->id, $defaults)) {
             $userlist[$locuser->id] = $locuser->firstname . ' ' . $locuser->lastname . ' (' . $locuser->username . ')';
         }
     }
     $form->register('users', gt('Users'), new listbuildercontrol($defaults, $userlist));
     // Get Group list
     $grouplist = array();
     $defaults = array();
     $groups = group::getAllGroups();
     if ($groups != null) {
         foreach ($db->selectObjects('formbuilder_address', 'form_id=' . $object->id . ' and group_id != 0') as $address) {
             $group = group::getGroupById($address->group_id);
             $defaults[$group->id] = $group->name;
         }
         foreach ($groups as $group) {
             if (!array_key_exists($group->id, $defaults)) {
                 $grouplist[$group->id] = $group->name;
             }
         }
         $form->register('groups', gt('Groups'), new listbuildercontrol($defaults, $grouplist));
     }
     // Get free-form address list
     $defaults = array();
     foreach ($db->selectObjects('formbuilder_address', 'form_id=' . $object->id . " and email != ''") as $address) {
         $defaults[$address->email] = $address->email;
     }
     $form->register('addresses', gt('Other Addresses'), new listbuildercontrol($defaults, null));
     $form->register('subject', gt('Email Subject'), new textcontrol($object->subject));
     $form->register(null, '', new htmlcontrol('<h3>' . gt('Database Settings') . '</h3><hr size="1" /><br />'));
     $form->register('is_saved', gt('Save Submissions to the Database'), new checkboxcontrol($object->is_saved, false));
     $form->register(null, '', new htmlcontrol('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . gt('To help prevent data loss, you cannot remove a form\'s database table once it has been added.') . '<br />'));
     if ($object->is_saved == 1) {
         $form->controls['is_saved']->disabled = true;
         $form->meta('is_saved', '1');
     }
     //		$form->register(null,'', new htmlcontrol('<br /><br /><br />'));
     $form->register('submit', '', new buttongroupcontrol(gt('Save'), '', gt('Cancel')));
     return $form;
 }
Beispiel #5
0
    //$groups = explode(';',$_POST['permdata']);
    $locarray = array();
    //	if ($loc->mod == 'navigationmodule' && (isset($_POST['permdata'][1]['manage']) && $_POST['permdata'][1]['manage'] || isset($_POST['permdata'][1]['administrate']) && $_POST['permdata'][1]['administrate'])) {
    //		$sections = navigationmodule::levelTemplate($loc->int);
    //		$locarray[] = $loc;
    //		foreach ($sections as $section) {
    //			$locarray[] = expCore::makeLocation('navigationmodule', null, $section->id);
    //		}
    //	} else {
    $locarray[] = $loc;
    //	}
    $groups = group::getAllGroups();
    foreach ($locarray as $location) {
        foreach ($groups as $g) {
            expPermissions::revokeAllGroup($g, $location);
        }
    }
    foreach ($_POST['permdata'] as $k => $group_str) {
        $perms = array_keys($group_str);
        $g = group::getGroupById($k);
        foreach ($locarray as $location) {
            for ($i = 0; $i < count($perms); $i++) {
                expPermissions::grantGroup($g, $perms[$i], $location);
            }
        }
    }
    expPermissions::triggerRefresh();
    expHistory::back();
} else {
    echo SITE_403_HTML;
}