Example #1
0
 /**
  * Returns the next (alphabetic) memberid
  * @param object $user current user object
  * @return next memberid as string
  */
 function get_next_userid(&$user)
 {
     $data = array($user->get_lname(), $user->get_lname(), $user->get_fname(), $user->get_id());
     $result = $this->db->getRow('SELECT memberid FROM ' . $this->get_table('login') . ' WHERE (' . ' (lname>?) ' . ' OR (lname=? AND fname>=?)' . ') ' . ' AND memberid <> ?' . ' ORDER BY lname, fname', $data);
     $this->check_for_error($result);
     if (count($result) <= 0) {
         return $user->get_id();
     }
     return $result['memberid'];
 }
    /**
     * Output name.
     * @param  object $item
     * @return string
     */
    public function column_plan_name($item)
    {
        $name = '
			<strong>
			  <a href="' . esc_url(add_query_arg('plan_id', $item->get_id(), admin_url('edit.php?post_type=product&page=deposit_payment_plans'))) . '">' . esc_html($item->get_name()) . '</a>
			</strong>
			<div class="row-actions">
				<a href="' . esc_url(add_query_arg('plan_id', $item->get_id(), admin_url('edit.php?post_type=product&page=deposit_payment_plans'))) . '">' . __('Edit', 'woocommerce-deposits') . '</a> | <a href="' . wp_nonce_url(add_query_arg('delete_plan', $item->get_id(), admin_url('edit.php?post_type=product&page=deposit_payment_plans')), 'delete_plan') . '" class="delete_plan">' . __('Delete', 'woocommerce-deposits') . '</a>
			</div>
		';
        return $name;
    }
/**
 * Get search results.
 * @param object $forum
 * @param int $groupid
 * @param string $author
 * @param int $daterangefrom
 * @param int $daterangeto
 * @param int $page
 * @param int $resultsperpage (FORUMNG_SEARCH_RESULTSPERPAGE used as constant)
 * @return object
 */
function forumng_get_results_for_this_forum($forum, $groupid, $author = null, $daterangefrom = 0, $daterangeto = 0, $page, $resultsperpage = FORUMNG_SEARCH_RESULTSPERPAGE)
{
    $before = microtime(true);
    global $CFG, $DB, $USER;
    require_once $CFG->dirroot . '/mod/forumng/mod_forumng.php';
    $forumngid = $forum->get_id();
    $context = $forum->get_context();
    $params = array();
    $where = "WHERE d.forumngid = ?";
    $params[] = $forumngid;
    //exclude deleted discussion/post
    $where .= " AND d.deleted = 0 AND p.deleted = 0 AND p.oldversion = 0 ";
    if ($author) {
        list($morewhere, $moreparams) = forumng_get_author_sql($author);
        $where .= $morewhere;
        $params = array_merge($params, $moreparams);
    }
    if ($daterangefrom && !is_array($daterangefrom)) {
        $where .= " AND p.modified>=?";
        $params[] = $daterangefrom;
    }
    if ($daterangeto && !is_array($daterangeto)) {
        $where .= " AND p.modified<=?";
        $params[] = $daterangeto;
    }
    if ($groupid) {
        $where .= " AND (d.groupid = ? OR d.groupid IS NULL)";
        $params[] = $groupid;
    }
    $sql = "SELECT p.modified, p.id, p.discussionid, p.userid, p.parentpostid,\n            p.subject AS title, p.message AS summary, u.username, u.firstname,\n            u.lastname, p2.subject\n            FROM {forumng_posts} p\n            INNER JOIN {forumng_discussions} d ON d.id = p.discussionid\n            INNER JOIN {user} u ON p.userid = u.id\n            INNER JOIN {forumng_posts} p2 ON p2.id = d.postid\n            {$where}\n            ORDER BY p.modified DESC, p.id ASC";
    $results = new stdClass();
    $results->success = 1;
    $results->numberofentries = 0;
    $results->done = 0;
    $posts = $DB->get_records_sql($sql, $params, $page, $resultsperpage);
    $groupposts = array();
    foreach ($posts as $post) {
        if (!$post->title) {
            //Add Re: if the post doesn't have a subject
            $post->title = get_string('re', 'forumng', $post->subject);
        }
        $post->title = s(strip_tags($post->title));
        $post->summary = s(strip_tags(shorten_text($post->summary, 250)));
        $post->url = $CFG->wwwroot . "/mod/forumng/discuss.php?d={$post->discussionid}" . $forum->get_clone_param(mod_forumng::PARAM_PLAIN) . "#p{$post->id}";
    }
    $results->results = $groupposts ? $groupposts : $posts;
    $results->searchtime = microtime(true) - $before;
    $results->numberofentries = count($results->results);
    if (count($results->results) < $resultsperpage) {
        $results->done = 1;
    } else {
        if (!($extrapost = $DB->get_records_sql($sql, $params, $page + $resultsperpage, 1))) {
            $results->done = 1;
        }
    }
    return $results;
}
Example #4
0
/**
 * Activates membership order if has been completed.
 *
 * @param object $order
 */
function cp_payments_handle_membership_completed($order)
{
    if ($order->get_items(CP_ITEM_MEMBERSHIP)) {
        $order->activate();
        if (!is_admin()) {
            $order_url = $order->get_url($order->get_id());
            if (did_action('wp_head')) {
                cp_js_redirect($order_url);
            } else {
                wp_redirect($order_url);
            }
        }
    }
}
Example #5
0
 /**
  * Add a rule
  *
  * @param object $entity Rule entity with new data to insert
  * @param int $language Language selection identifier; default: 0
  * @param int $parent_id Category to display rules from; default: 0
  * @return rule_interface Added rule entity
  * @access public
  */
 public function add_rule($entity, $language = 0, $parent_id = 0)
 {
     // Insert the rule data to the database for the given language selection
     $entity->insert($language);
     // Get the newly inserted rule's identifier
     $rule_id = $entity->get_id();
     // Update the tree for the rule in the database
     $this->nestedset_rules->add_to_nestedset($rule_id);
     // If a parent id was supplied, update the rule's parent id and tree ids
     if ($parent_id) {
         $this->nestedset_rules->change_parent($rule_id, $parent_id);
     }
     // Reload the data to return a fresh rule entity
     return $entity->load($rule_id);
 }
 /**
  * @brief Check if this element is a child of another element (recursive)
  *
  * @param object $another_element       the object to compare
  *                                      IMPORTANT: both objects to compare must be from the same class (for example two "Device" objects)!
  *
  * @retval true|false
  *
  * @throws Exception if there was an error
  */
 public function is_child_of($another_element)
 {
     if ($this->get_id() == NULL) {
         return false;
     } else {
         $class_name = get_class($this);
         $parent_element = new $class_name($this->database, $this->current_user, $this->log, $this->get_parent_id());
         return $parent_element->get_id() == $another_element->get_id() || $parent_element->is_child_of($another_element);
     }
 }
 /**
  * getHash
  *
  * @param   object  $item  Params
  *
  * @return	void
  */
 public static function getHash($item)
 {
     return md5($item->get_id());
 }
Example #8
0
/**
 * Sends email notification to admin if payment failed.
 *
 * @param object $order
 */
function cp_send_admin_failed_transaction($order)
{
    if (is_admin() && !defined('DOING_AJAX')) {
        return;
    }
    $blogname = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
    $subject = sprintf(__('[%1$s] Failed Order #%2$d', APP_TD), $blogname, $order->get_id());
    $content = '';
    $content .= html('p', sprintf(__('Payment for the order #%s has failed.', APP_TD), $order->get_id()));
    $content .= html('p', sprintf(__('Please <a href="%s">review this order</a>, and if necessary disable assigned services.', APP_TD), get_edit_post_link($order->get_id())));
    $email = array('to' => get_option('admin_email'), 'subject' => $subject, 'message' => $content);
    $email = apply_filters('cp_email_admin_transaction_failed', $email, $order);
    appthemes_send_email($email['to'], $email['subject'], $email['message']);
}
 /**
  * Check for required items on all groups and for all components registered to the location.
  * @param object $check_list
  * @return bool
  **/
 private function _check_for_required($check_list)
 {
     $ok = true;
     $control = $this->so_control->get_single($check_list->get_control_id());
     $saved_control_groups = $this->so_control_group_list->get_control_groups_by_control($control->get_id());
     $required_control_items = array();
     foreach ($saved_control_groups as $control_group) {
         $control_items = $this->so_control_item_list->get_control_items_and_options_by_control_and_group($control->get_id(), $control_group->get_id(), "return_array");
         $component_location_id = $control_group->get_component_location_id();
         $component_criteria = $control_group->get_component_criteria();
         foreach ($control_items as $control_item) {
             if ($control_item['required']) {
                 $control_item['component_location_id'] = $component_location_id;
                 $control_item['component_criteria'] = $component_criteria;
                 $required_control_items[] = $control_item;
             }
         }
     }
     $components_at_location = array();
     $control_groups_with_items_array = array();
     $component_id = $check_list->get_component_id();
     if ($component_id > 0) {
         $location_id = $check_list->get_location_id();
         $component_id = $check_list->get_component_id();
         foreach ($required_control_items as $required_control_item) {
             $_ok = $this->so_case->get_cases_by_component($location_id, $component_id, $required_control_item['id'], $check_list->get_id());
             if (!$_ok) {
                 $error_message = lang('missing value for required') . "</br>";
                 $error_message .= "\"{$required_control_item['title']}\"</br>";
                 $error_message .= execMethod('property.soentity.get_short_description', array('location_id' => $location_id, 'id' => $component_id));
                 $error_message .= "</br>";
                 phpgwapi_cache::message_set($error_message, 'error');
                 //						echo $error_message;
                 $ok = false;
             }
         }
     } else {
         $location_code = $check_list->get_location_code();
         $location_code_search_components = $location_code;
         $type = 'location';
         foreach ($required_control_items as $required_control_item) {
             $criterias_array = array();
             $component_location_id = $required_control_item['component_location_id'];
             $criterias_array['location_id'] = $component_location_id;
             $criterias_array['location_code'] = $location_code_search_components;
             $criterias_array['allrows'] = true;
             $component_criteria = $required_control_item['component_criteria'];
             $conditions = array();
             foreach ($component_criteria as $attribute_id => $condition) {
                 if ($condition['value']) {
                     eval('$condition_value = ' . "{$condition['value']};");
                     $conditions[] = array('attribute_id' => $attribute_id, 'operator' => $condition['operator'], 'value' => $condition_value);
                 }
             }
             $criterias_array['conditions'] = $conditions;
             if (!isset($components_at_location[$component_location_id][$location_code_search_components]) || !($_components_at_location = $components_at_location[$component_location_id][$location_code_search_components])) {
                 $_components_at_location = execMethod('property.soentity.get_eav_list', $criterias_array);
                 $components_at_location[$component_location_id][$location_code_search_components] = $_components_at_location;
             }
             if ($_components_at_location) {
                 foreach ($_components_at_location as &$_component_at_location) {
                     $_ok = $this->so_case->get_cases_by_component($_component_at_location['location_id'], $_component_at_location['id'], $required_control_item['id'], $check_list->get_id());
                     if (!$_ok) {
                         $error_message = "mangler registrering for required</br>";
                         $error_message .= "{$required_control_item['title']}</br>";
                         $error_message .= execMethod('property.soentity.get_short_description', array('location_id' => $_component_at_location['location_id'], 'id' => $_component_at_location['id']));
                         $error_message .= "</br>";
                         phpgwapi_cache::message_set($error_message, 'error');
                         //								echo $error_message;
                         $ok = false;
                     }
                 }
             }
         }
     }
     $config = CreateObject('phpgwapi.config', 'controller');
     $config->read();
     $required_actual_hours = isset($config->config_data['required_actual_hours']) && $config->config_data['required_actual_hours'] ? $config->config_data['required_actual_hours'] : false;
     if ($check_list->get_status == controller_check_list::STATUS_DONE && $required_actual_hours && $check_list->get_billable_hours() == 0) {
         phpgwapi_cache::message_set(lang("Please enter billable hours"), 'error');
         $ok = false;
     }
     return $ok;
 }
Example #10
0
 /**
  * Sends notification to admin
  *
  * @param object $report
  *
  * @return void
  */
 public static function notify_admin($report)
 {
     $options = appthemes_load_reports_options();
     if (!$options->get(array('reports', 'send_email'))) {
         return;
     }
     // notify only once per post about report
     $reports = appthemes_get_post_reports($report->get_post_ID());
     if (count($reports->reports) > 1) {
         return;
     }
     $emails = apply_filters('comment_notification_recipients', array(), $report->get_id());
     $subject = apply_filters('comment_notification_subject', '', $report->get_id());
     $notify_message = apply_filters('comment_notification_text', '', $report->get_id());
     foreach ($emails as $email) {
         appthemes_send_email($email, $subject, $notify_message);
     }
 }
 /**
  * movement_last_accessories tests if the $field has been given in last
  * movement 
  * 
  * @param object $field field object to test
  * @return bool true, if accessorie given, false otherwise
  */
 public function movement_last_accessories($field)
 {
     // get db-object
     $db = Db::newDb();
     // get last movements
     $id = Inventory::movement_last_row($db, $this->get_id(), 'id');
     // prepare sql-statement
     $sql = "SELECT v.value\n\t\t\t\tFROM value AS v\n\t\t\t\tWHERE table_name = 'inventory_movement'\n\t\t\t\tAND table_id = " . $id[0] . "\n\t\t\t\tAND field_id = " . $field->get_id();
     // execute
     $result = $db->query($sql);
     // fetch result
     list($value) = $result->fetch_array(MYSQL_NUM);
     // return
     if ($value == 1) {
         return true;
     } else {
         return false;
     }
 }
Example #12
0
 /**
  * Checks if user can access checkout step, if not, cancel or finish current step.
  *
  * @param object $order
  * @param object $checkout
  *
  * return bool
  */
 public function can_access_step($order, $checkout)
 {
     // if order not created move step backward
     if (!$order->get_id()) {
         $checkout->cancel_step();
         return false;
     }
     return true;
 }
 /**
  * read_preset_form generates a quickform-object to choose the announcement-preset,
  * if validated redirect to announcement.php?id=new&cid=$id
  * 
  * @param object $calendar the actual calendarentry
  * @return object quickform-object to choose the preset, if validated redirect to new announcement
  */
 private function read_preset_form(&$calendar)
 {
     // check sort or from/to
     $sort = $from = $to = '';
     if ($this->get('sort') !== false) {
         $sort = "&sort=" . $this->get('sort');
     }
     if ($this->get('from') !== false) {
         $from = "&from=" . $this->get('from');
     }
     if ($this->get('to') !== false) {
         $to = "&to=" . $this->get('to');
     }
     // form-object
     $form = new HTML_QuickForm2('choose_preset_' . $calendar->get_id(), 'post', array('name' => 'choose_preset_' . $calendar->get_id(), 'action' => 'calendar.php?id=listall' . $sort . $from . $to));
     // add selectfield
     $select = $form->addSelect('preset', array());
     $options = array(0 => parent::lang('class.CalendarView#read_preset_form#select#choosePreset'));
     $options = $options + Preset::read_all_presets('calendar');
     $select->loadOptions($options);
     $select->addRule('callback', parent::lang('class.CalendarView#read_preset_form#rule#select'), array($this, 'callback_check_select'));
     // add submit
     $submit = $form->addSubmit('submit', array('value' => parent::lang('class.CalendarView#read_preset_form#select#submit')));
     // validate
     if ($form->validate()) {
         // get data
         $data = $form->getValue();
         // insert preset_id in calendar-entry
         $update = array('preset_id' => $data['preset']);
         $calendar->update($update);
         $calendar->write_db('update');
         // redirect to listall
         header('Location: calendar.php?id=listall' . $sort . $from . $to);
         exit;
     } else {
         return $form;
     }
 }
Example #14
0
/**
 * Format admin settings
 *
 * @param object $setting
 * @param string $title label element
 * @param string $form form fragment, html code - not highlighted automatically
 * @param string $description
 * @param mixed $label link label to id, true by default or string being the label to connect it to
 * @param string $warning warning text
 * @param sting $defaultinfo defaults info, null means nothing, '' is converted to "Empty" string, defaults to null
 * @param string $query search query to be highlighted
 * @return string XHTML
 */
function format_admin_setting($setting, $title='', $form='', $description='', $label=true, $warning='', $defaultinfo=NULL, $query='') {
    global $CFG, $OUTPUT;

    $context = (object) [
        'name' => empty($setting->plugin) ? $setting->name : "$setting->plugin | $setting->name",
        'fullname' => $setting->get_full_name(),
    ];

    // Sometimes the id is not id_s_name, but id_s_name_m or something, and this does not validate.
    if ($label === true) {
        $context->labelfor = $setting->get_id();
    } else if ($label === false) {
        $context->labelfor = '';
    } else {
        $context->labelfor = $label;
    }

    $form .= $setting->output_setting_flags();

    $context->warning = $warning;
    $context->override = '';
    if (empty($setting->plugin)) {
        if (array_key_exists($setting->name, $CFG->config_php_settings)) {
            $context->override = get_string('configoverride', 'admin');
        }
    } else {
        if (array_key_exists($setting->plugin, $CFG->forced_plugin_settings) and array_key_exists($setting->name, $CFG->forced_plugin_settings[$setting->plugin])) {
            $context->override = get_string('configoverride', 'admin');
        }
    }

    $defaults = array();
    if (!is_null($defaultinfo)) {
        if ($defaultinfo === '') {
            $defaultinfo = get_string('emptysettingvalue', 'admin');
        }
        $defaults[] = $defaultinfo;
    }

    $context->default = null;
    $setting->get_setting_flag_defaults($defaults);
    if (!empty($defaults)) {
        $defaultinfo = implode(', ', $defaults);
        $defaultinfo = highlight($query, nl2br(s($defaultinfo)));
        $context->default = get_string('defaultsettinginfo', 'admin', $defaultinfo);
    }


    $context->error = '';
    $adminroot = admin_get_root();
    if (array_key_exists($context->fullname, $adminroot->errors)) {
        $context->error = $adminroot->errors[$context->fullname]->error;
    }

    $context->id = 'admin-' . $setting->name;
    $context->title = highlightfast($query, $title);
    $context->name = highlightfast($query, $context->name);
    $context->description = highlight($query, markdown_to_html($description));
    $context->element = $form;
    $context->forceltr = $setting->get_force_ltr();

    return $OUTPUT->render_from_template('core_admin/setting', $context);
}
Example #15
0
/**
* Prints the form to reset a users password
* @param object $user user object
*/
function print_reset_password(&$user)
{
    ?>
<form name="resetpw" method="post" action="admin_update.php">
  <table border="0" cellspacing="0" cellpadding="1" width="50%">
    <tr>
      <td class="tableBorder">
        <table cellspacing="1" cellpadding="2" border="0" width="100%">
          <tr class="rowHeaders">
		  	<td colspan="2"><?php 
    echo translate('Reset Password for', array($user->get_name()));
    ?>
</td>
		  </tr>
		  <tr class="cellColor">
            <td width="15%" valign="top"><?php 
    echo translate('Password');
    ?>
</td>
			<td><input type="password" value="" class="textbox" name="password" />
			<br />
			<i><?php 
    echo translate('If no value is specified, the default password set in the config file will be used.');
    ?>
</i>
			</td>
          </tr>
		  <tr class="cellColor">
		    <td colspan="2"><input type="checkbox" name="notify_user" value="true" checked="checked"/><?php 
    echo translate('Notify user that password has been changed?');
    ?>
</td>
		  </tr>
        </table>
      </td>
    </tr>
  </table>
  <input type="hidden" name="memberid" value="<?php 
    echo $user->get_id();
    ?>
" />
  <br />
  <?php 
    echo submit_button(translate('Save')) . hidden_fn('resetPass');
    ?>
  <input type="button" name="cancel" value="<?php 
    echo translate('Manage Users');
    ?>
" class="button" onclick="document.location='<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
?tool=users';" />
</form>
<?php 
}
 /**
  * get_movements returns the htmlstring of the movements
  * 
  * @param object $inventory the inventory object
  * @return string html of the movement list
  */
 private function get_movements($inventory)
 {
     // get id
     $id = $inventory->get_id();
     // get preset
     $preset = $inventory->get_preset();
     // get fields
     $fields = $preset->get_fields();
     // get db-object
     $db = Db::newDb();
     // prepare sql-statement
     $sql = "SELECT u.name,m.id,m.date_time\n\t\t\t\tFROM user AS u, inventory_movement AS m\n\t\t\t\tWHERE m.action = 'taken'\n\t\t\t\tAND m.inventory_id = {$id}\n\t\t\t\tAND u.id = m.user_id\n\t\t\t\tORDER BY m.date_time DESC";
     // execute
     $result = $db->query($sql);
     $movements = array();
     while (list($name, $movement_id, $date_time) = $result->fetch_array(MYSQL_NUM)) {
         // smarty
         $movements[] = array('href' => 'inventory.php?id=movement&mid=' . $movement_id, 'title' => parent::lang('class.InventoryView#get_movements#date#title'), 'content' => date('d.m.Y', strtotime($date_time)), 'name' => $name);
     }
     // return
     return $movements;
 }
Example #17
0
 /**
  * Duplicates an order.
  *
  * @param object $original The Order object
  *
  * @return object|bool APP_Order New Order object. Boolean False on failure.
  */
 public static function duplicate($original)
 {
     $duplicate = self::make($original->get_description());
     if (!$duplicate) {
         return false;
     }
     $duplicate->set_gateway($original->get_gateway());
     $duplicate->set_currency($original->get_currency());
     $duplicate->set_author($original->get_author());
     if ($original->is_recurring()) {
         $duplicate->set_recurring_period($original->get_recurring_period(), $original->get_recurring_period_type());
     }
     foreach ($original->get_items() as $item) {
         $duplicate->add_item($item['type'], $item['price'], $item['post_id']);
     }
     if ($original->get_id() != 0) {
         $original->log('Order Duplicated. Created ' . html_link(get_edit_post_link($duplicate->get_id()), 'Order #' . $duplicate->get_id()), 'info');
         $duplicate->log('Order Duplicated from ' . html_link(get_edit_post_link($original->get_id()), 'Order #' . $original->get_id()), 'info');
     }
     do_action('appthemes_create_order_duplicate', $duplicate, $original);
     return $duplicate;
 }
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     global $transaction;
     if ($event_object instanceof ItemAddHolderEvent) {
         $type = $event_object->get_type();
         if ($type == "sample") {
             $sample_id = $event_object->get_id();
             $item_id = $event_object->get_item_id();
             $gid = $event_object->get_gid();
             $transaction_id = $transaction->begin();
             if (self::create($sample_id, $item_id, $gid, null, null) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             } else {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
             }
         }
     }
     if ($event_object instanceof ItemAddEvent) {
         $get_array = $event_object->get_get_array();
         $post_array = $event_object->get_post_array();
         $item_holder = $event_object->get_item_holder();
         $item_holder_name = $event_object->get_item_holder_name();
         if ($get_array['nav'] == "sample" and is_numeric($get_array['sample_id']) and !$get_array['parent'] and !$get_array['parent_key']) {
             $transaction_id = $transaction->begin();
             if ($get_array['parent_sample'] == "1") {
                 $parent = true;
             } else {
                 $parent = false;
             }
             if ($item_holder == true and $item_holder_name) {
                 $item_holder_class = Item::get_holder_handling_class_by_name($item_holder_name);
                 $item_holder_instance = $item_holder_class::get_instance_by_item_id($event_object->get_item_id());
                 if (self::$sample_instance_array[$get_array['sample_id']]) {
                     $sample = self::$sample_instance_array[$get_array['sample_id']];
                 } else {
                     $sample = new Sample($get_array['sample_id']);
                     self::$sample_instance_array[$get_array['sample_id']] = $sample;
                 }
                 $required_sub_item_array = $sample->list_required_sub_items($get_array['key']);
                 if (is_array($required_sub_item_array) and count($required_sub_item_array) >= 1) {
                     if ($required_sub_item_array[0] == "all") {
                         $sub_item_array = $item_holder_instance->get_item_holder_items(null);
                         if (is_array($sub_item_array) and count($sub_item_array)) {
                             foreach ($sub_item_array as $sub_item_key => $sub_item_value) {
                                 if (self::create($get_array['sample_id'], $sub_item_value, null, null, null, $event_object->get_item_id()) == false) {
                                     if ($transaction_id != null) {
                                         $transaction->rollback($transaction_id);
                                     }
                                     return false;
                                 }
                                 if (DataEntity::is_kind_of("file", $sub_item_value) or DataEntity::is_kind_of("value", $sub_item_value) or DataEntity::is_kind_of("parameter", $sub_item_value)) {
                                     $data_entity_id = DataEntity::get_entry_by_item_id($sub_item_value);
                                     $folder_id = $sample->get_item_holder_value("folder_id");
                                     $parent_data_entity_id = Folder::get_data_entity_id_by_folder_id($folder_id);
                                     $child_data_entity = new DataEntity($data_entity_id);
                                     if ($child_data_entity->set_as_child_of($parent_data_entity_id, true, $parent_item_id) == false) {
                                         return false;
                                     }
                                 }
                             }
                         }
                     } else {
                         foreach ($required_sub_item_array as $key => $value) {
                             $sub_item_array = $item_holder_instance->get_item_holder_items($value);
                             if (is_array($sub_item_array) and count($sub_item_array)) {
                                 foreach ($sub_item_array as $sub_item_key => $sub_item_value) {
                                     if (self::create($get_array['sample_id'], $sub_item_value, null, null, null, $event_object->get_item_id()) == false) {
                                         if ($transaction_id != null) {
                                             $transaction->rollback($transaction_id);
                                         }
                                         return false;
                                     }
                                     if (DataEntity::is_kind_of("file", $sub_item_value) or DataEntity::is_kind_of("value", $sub_item_value) or DataEntity::is_kind_of("parameter", $sub_item_value)) {
                                         $data_entity_id = DataEntity::get_entry_by_item_id($sub_item_value);
                                         $folder_id = $sample->get_item_holder_value("folder_id");
                                         $parent_data_entity_id = Folder::get_data_entity_id_by_folder_id($folder_id);
                                         $child_data_entity = new DataEntity($data_entity_id);
                                         if ($child_data_entity->set_as_child_of($parent_data_entity_id, true, $parent_item_id) == false) {
                                             return false;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if (self::create($get_array['sample_id'], $event_object->get_item_id(), $get_array['key'], $post_array['keywords'], $post_array['description'], null, $parent) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             } else {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
             }
         }
         if (($get_array['parent'] == "sample" or $get_array['parent'] == "parentsample") and is_numeric($get_array['key']) and is_numeric($get_array['parent_key'])) {
             $transaction_id = $transaction->begin();
             if (is_numeric($get_array['parent_id'])) {
                 if ($get_array['parent'] == "parentsample") {
                     $parent_sample = true;
                 } else {
                     $parent_sample = false;
                 }
                 if (self::create($get_array['parent_id'], $event_object->get_item_id(), $get_array['key'], null, null, null, false, $parent_sample) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     return false;
                 } else {
                     if ($transaction_id != null) {
                         $transaction->commit($transaction_id);
                     }
                 }
             } elseif ($get_array['nav']) {
                 $handling_class = Item::get_holder_handling_class_by_name($get_array['nav']);
                 if (class_exists($handling_class)) {
                     $item_holder = new $handling_class($get_array[$get_array['nav'] . '_id']);
                     $parent_id_array = $item_holder->get_item_add_information($get_array['parent_key']);
                     if (is_array($parent_id_array['fulfilled']) and count($parent_id_array['fulfilled']) >= 1) {
                         foreach ($parent_id_array['fulfilled'] as $key => $value) {
                             if (self::create($value['id'], $event_object->get_item_id(), $get_array['key']) == false) {
                                 if ($transaction_id != null) {
                                     $transaction->rollback($transaction_id);
                                 }
                                 return false;
                             }
                         }
                         if ($transaction_id != null) {
                             $transaction->commit($transaction_id);
                         }
                     }
                 } else {
                     return false;
                 }
             }
         }
     }
     if ($event_object instanceof ItemHolderAddEvent) {
         $id_array = $event_object->get_id_array();
         $item_id = $event_object->get_item_id();
         $parent_item_id = $event_object->get_parent_item_id();
         $pos_id = $event_object->get_pos_id();
         if (is_array($id_array) and count($id_array) >= 1) {
             if (is_array($id_array['sample']) and count($id_array['sample']) >= 1) {
                 foreach ($id_array['sample'] as $key => $value) {
                     $sample = new Sample($value['id']);
                     if ($sample->is_sub_item_required($value['pos_id'], $pos_id) == true) {
                         if (self::create($value['id'], $item_id, null, null, null, $parent_item_id, false) == false) {
                             return false;
                         }
                         if (DataEntity::is_kind_of("file", $item_id) or DataEntity::is_kind_of("value", $item_id) or DataEntity::is_kind_of("parameter", $sub_item_value)) {
                             $data_entity_id = DataEntity::get_entry_by_item_id($item_id);
                             $folder_id = $sample->get_item_holder_value("folder_id");
                             $parent_data_entity_id = Folder::get_data_entity_id_by_folder_id($folder_id);
                             $child_data_entity = new DataEntity($data_entity_id);
                             if ($child_data_entity->set_as_child_of($parent_data_entity_id, true, $parent_item_id) == false) {
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
 /**
  * Adds party and sets idref
  *
  * @param object $party rs_opentrans_document_party
  * @return void
  */
 public function add_party($party)
 {
     if (!$party instanceof rs_opentrans_document_party) {
         throw new rs_opentrans_exception('$party must be type of rs_opentrans_document_party.');
     }
     $this->parties[] = $party;
     $this->idrefs[] = new rs_opentrans_document_idref($party->get_id()->get_id(), $party->get_role());
 }
Example #20
0
/**
* Prints all the buttons and hidden fields
* @param object $res Reservation object to work with
*/
function print_buttons_and_hidden(&$res)
{
    ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td>
<?php 
    $is_owner = $res->user->get_id() == Auth::getCurrentID();
    $type = $res->get_type();
    // Print buttons depending on type
    echo '<p>';
    switch ($type) {
        case RES_TYPE_MODIFY:
            echo '<input type="submit" name="btnSubmit" value="' . translate('Save') . '" class="button" onclick="selectAllOptions(this);"/>' . '<input type="hidden" name="fn" value="modify" />';
            break;
        case RES_TYPE_DELETE:
            echo '<input type="submit" name="btnSubmit" value="' . translate('Delete') . '" class="button" />' . '<input type="hidden" name="fn" value="delete" />';
            break;
        case RES_TYPE_VIEW:
            echo '<input type="button" name="close" value="' . translate('Close Window') . '" class="button" onclick="window.close();" />';
            break;
        case RES_TYPE_ADD:
            echo '<input type="submit" name="btnSubmit" value="' . translate('Save') . '" class="button" onclick="selectAllOptions(this);"/>' . '<input type="hidden" name="fn" value="create" />';
            break;
        case RES_TYPE_APPROVE:
            echo '<input type="submit" name="btnSubmit" value="' . translate('Approve') . '" class="button"/>' . '<input type="hidden" name="fn" value="approve" />';
    }
    // Print cancel button as long as type is not "view"
    if ($type != RES_TYPE_VIEW) {
        echo '&nbsp;&nbsp;&nbsp;<input type="button" name="close" value="' . translate('Cancel') . '" class="button" onclick="window.close();" />';
    }
    if ($type != RES_TYPE_ADD && $is_owner) {
        // echo '&nbsp;&nbsp;';
        // print_export_button($res->id);
    }
    echo '</p>';
    if ($type == RES_TYPE_ADD || $type == RES_TYPE_MODIFY) {
        echo '</td><td align="right"><button type="button" name="check" value="' . translate('Check Availability') . '" class="button" onclick="checkReservation(\'check.php\', \'reserve\', \'' . translate('Checking') . '\');">' . translate('Check Availability') . '</button></td><td>';
    }
    // print hidden fields
    if ($res->get_type() == RES_TYPE_ADD) {
        echo '<input type="hidden" name="machid" value="' . $res->get_machid() . '" />' . "\n" . '<input type="hidden" name="scheduleid" value="' . $res->sched['scheduleid'] . '" />' . "\n" . '<input type="hidden" name="pending" value="' . $res->get_pending() . '" />' . "\n" . '<input type="hidden" name="memberid" value="' . Auth::getCurrentID() . '" />' . "\n";
    } else {
        echo '<input type="hidden" name="resid" id="resid" value="' . $res->get_id() . '" />' . "\n" . '<input type="hidden" name="memberid" value="' . $res->get_memberid() . '" />' . "\n";
    }
    ?>
    </td>
  </tr>
  <?php 
    if ($type == RES_TYPE_ADD || $type == RES_TYPE_MODIFY) {
        echo '<tr><td colspan="2"><div id="checkDiv" style="display:none;width:100%;padding-top:15px;"></div></td></tr>';
    }
    ?>
</table>
<?php 
}
Example #21
0
 /**
  * Renders flagged discussion list details
  * @param object $discussion
  * @param boolean $last
  * @return string
  */
 public function render_flagged_discuss_list_item($discussion, $last)
 {
     global $CFG, $USER;
     $result = '';
     // Work out CSS classes to use for discussion.
     $classes = '';
     $alts = array();
     $icons = array();
     if ($discussion->is_deleted()) {
         $classes .= ' forumng-deleted';
         $alts[] = get_string('alt_discussion_deleted', 'forumng');
         $icons[] = array();
         // No icon, text will be output on its own.
     }
     // Classes for Moodle table styles.
     static $rownum = 0;
     $classes .= ' r' . $rownum;
     $rownum = 1 - $rownum;
     if ($last) {
         $classes .= ' lastrow';
     }
     $courseid = $discussion->get_forum()->get_course_id();
     // Start row.
     $result = "<tr id='discrow_{$discussion->get_id()}' class='forumng-discussion-short{$classes}'>";
     // Subject, with icons.
     $result .= "<td class='forumng-subject cell c0'>";
     // Show flag icon.
     $result .= ' <form class="forumng-flag" action="feature/flagdiscussion/flag.php" method="post"><div>' . '<input type="hidden" name="d" value="' . $discussion->get_id() . '" />' . '<input type="hidden" name="back" value="view" />' . '<input type="hidden" name="flag" value="0" />' . '<input type="image" title="' . get_string('clearflag', 'forumng') . '" src="' . $this->pix_url('flag.on', 'mod_forumng') . '" alt="' . get_string('flagon', 'forumng') . '" /></div></form>&nbsp;';
     $result .= "<a href='discuss.php?" . $discussion->get_link_params(mod_forumng::PARAM_HTML) . "'>" . format_string($discussion->get_subject(true), true, $courseid) . "</a>";
     $result .= '</td>';
     // Author.
     $lastposteranon = $discussion->get_last_post_anon();
     $result .= $this->render_discussion_list_item_author($discussion, $courseid);
     $num = 2;
     // Update last post user profile link.
     // Last post.
     $lastpostcell = $this->render_discussion_list_item_lastpost($discussion, $lastposteranon, $num);
     $result .= $lastpostcell . "</tr>";
     return $result;
 }
/**
 * Builds the course or platform admin icons to edit an evaluation
 * @param object $eval evaluation object
 * @param int $selectcat id of selected category
 */
function build_edit_icons_eval($eval, $selectcat)
{
    $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
    $is_locked = $eval->is_locked();
    $eval->get_course_code();
    $cat = new Category();
    $message_eval = $cat->show_message_resource_delete($eval->get_course_code());
    if ($message_eval === false && api_is_allowed_to_edit(null, true)) {
        $visibility_icon = $eval->is_visible() == 0 ? 'invisible' : 'visible';
        $visibility_command = $eval->is_visible() == 0 ? 'set_visible' : 'set_invisible';
        if ($is_locked && !api_is_platform_admin()) {
            $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
        } else {
            $modify_icons = '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . ' &amp;cidReq=' . $eval->get_course_code() . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
        }
        $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visibleeval=' . $eval->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . ' ">' . Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>';
        if (api_is_allowed_to_edit(null, true)) {
            $modify_icons .= '&nbsp;<a href="gradebook_showlog_eval.php?visiblelog=' . $eval->get_id() . '&amp;selectcat=' . $selectcat . ' &amp;cidReq=' . $eval->get_course_code() . '">' . Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>';
        }
        /*
        		if ($locked_status == 0){
        			$modify_icons .= "&nbsp;<a href=\"javascript:if (confirm('".addslashes(get_lang('AreYouSureToLockedTheEvaluation'))."')) { location.href='".api_get_self().'?lockedeval=' . $eval->get_id() . '&amp;selectcat=' . $selectcat . ' &amp;cidReq='.$eval->get_course_code()."'; }\">".Display::return_icon('unlock.png',get_lang('LockEvaluation'), array(), ICON_SIZE_SMALL)."</a>";
        		} else {
        			if (api_is_platform_admin()){
        				$modify_icons .= "&nbsp;<a href=\"javascript:if (confirm('".addslashes(get_lang('AreYouSureToUnLockedTheEvaluation'))."')) { location.href='".api_get_self().'?lockedeval=' . $eval->get_id() . '&amp;typelocked=&amp;selectcat=' . $selectcat . ' &amp;cidReq='.$eval->get_course_code()."';\">".Display::return_icon('lock.png',get_lang('UnLockEvaluation'), array(), ICON_SIZE_SMALL)."</a>";
        			} else {
        				$modify_icons .= '&nbsp;<img src="../img/locked_na.png" border="0" title="' . get_lang('TheEvaluationIsLocked') . '" alt="" />';
        			}
        		}*/
        if ($is_locked && !api_is_platform_admin()) {
            $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
        } else {
            $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deleteeval=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &amp;cidReq=' . $eval->get_course_code() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
        }
        return $modify_icons;
    }
}
Example #23
0
 /**
  * Export Submissions
  *
  * A wrapper for the Submission Model export method.
  *
  * @param array $sub_ids
  * @param bool|FALSE $return
  * @return string
  */
 public function export_subs(array $sub_ids = array(), $return = FALSE)
 {
     $form_id = $this->_object->get_id();
     return NF_Database_Models_Submission::export($form_id, $sub_ids, $return);
 }
Example #24
0
 /**
  * Returns reports table row
  *
  * @param object $item
  *
  * @return string
  */
 protected function row($item)
 {
     $author_info = html('strong', get_comment_author($item->get_id())) . '<br />';
     $author_email = get_comment_author_email($item->get_id());
     if (!empty($author_email)) {
         $author_info .= html_link('mailto:' . $author_email, $author_email) . '<br />';
     }
     $author_info .= get_comment_author_IP($item->get_id());
     $cells = array($author_info, get_comment_text($item->get_id()), get_comment_date('', $item->get_id()), '<span class="delete ui-icon ui-icon-circle-minus"></span>');
     return html('tr id="report-' . $item->get_id() . '"', array(), $this->cells($cells));
 }
Example #25
0
 /**
  * Build pull down menu options of available rule parents
  *
  * @param object $entity The rule entity object
  * @param int $language Language selection identifier; default: 0
  * @param int $parent_id Category to display rules from; default: 0
  * @param string $mode Display menu for add or edit mode
  * @return null
  * @access protected
  */
 protected function build_parent_select_menu($entity, $language = 0, $parent_id = 0, $mode = 'edit')
 {
     $language = $mode == 'edit' ? $entity->get_language() : $language;
     $parent_id = $mode == 'edit' ? $entity->get_parent_id() : $parent_id;
     // Prepare rule pull-down field
     $rule_menu_items = $this->rule_operator->get_rules($language);
     $padding = '';
     $padding_store = array();
     $right = 0;
     // Process each rule menu item for pull-down
     /* @var $rule_menu_item \phpbb\boardrules\entity\rule */
     foreach ($rule_menu_items as $rule_menu_item) {
         if ($rule_menu_item->get_left_id() < $right) {
             $padding .= '&nbsp;&nbsp;';
             $padding_store[$rule_menu_item->get_parent_id()] = $padding;
         } else {
             if ($rule_menu_item->get_left_id() > $right + 1) {
                 $padding = isset($padding_store[$rule_menu_item->get_parent_id()]) ? $padding_store[$rule_menu_item->get_parent_id()] : '';
             }
         }
         $right = $rule_menu_item->get_right_id();
         // Set output block vars for display in the template
         $this->template->assign_block_vars('rulemenu', array('RULE_ID' => $rule_menu_item->get_id(), 'RULE_TITLE' => $padding . $rule_menu_item->get_title(), 'S_DISABLED' => $mode == 'edit' && ($rule_menu_item->get_left_id() > $entity->get_left_id() && $rule_menu_item->get_right_id() < $entity->get_right_id() || $rule_menu_item->get_id() == $entity->get_id()) ? true : false, 'S_RULE_PARENT' => $rule_menu_item->get_id() == $parent_id));
     }
 }
Example #26
0
 /**
  * Process page data to be added or edited
  *
  * @param object $entity The page entity object
  * @return null
  * @access protected
  */
 protected function add_edit_page_data($entity)
 {
     // Create an array to collect errors that will be output to the user
     $errors = array();
     // Is the form submitted
     $submit = $this->request->is_set_post('submit');
     // Load posting language file for the BBCode editor
     $this->user->add_lang('posting');
     // Add form key for form validation checks
     add_form_key('add_edit_page');
     // Collect form data
     $data = array('page_title' => $this->request->variable('page_title', '', true), 'page_route' => $this->request->variable('page_route', ''), 'page_description' => $this->request->variable('page_description', '', true), 'page_content' => $this->request->variable('page_content', '', true), 'bbcode' => $this->request->variable('parse_bbcode', false), 'magic_url' => $this->request->variable('parse_magic_url', false), 'smilies' => $this->request->variable('parse_smilies', false), 'html' => $this->request->variable('parse_html', false), 'page_template' => $this->request->variable('page_template', ''), 'page_links' => $this->request->variable('page_links', array(0)), 'page_order' => $this->request->variable('page_order', 0), 'page_display' => $this->request->variable('page_display', 0), 'page_display_to_guests' => $this->request->variable('page_guest_display', 0));
     // Grab the form data's message parsing options (possible values: 1 or 0)
     // If submit use the data from the form
     // If page edit use data stored in the entity
     // If page add use default values
     $content_parse_options = array('bbcode' => $submit ? $data['bbcode'] : ($entity->get_id() ? $entity->content_bbcode_enabled() : 1), 'magic_url' => $submit ? $data['magic_url'] : ($entity->get_id() ? $entity->content_magic_url_enabled() : 1), 'smilies' => $submit ? $data['smilies'] : ($entity->get_id() ? $entity->content_smilies_enabled() : 1), 'html' => $submit ? $data['html'] : ($entity->get_id() ? $entity->content_html_enabled() : 0));
     // Set the content parse options in the entity
     foreach ($content_parse_options as $function => $enabled) {
         call_user_func(array($entity, ($enabled ? 'content_enable_' : 'content_disable_') . $function));
     }
     // Purge temporary variable
     unset($content_parse_options);
     // If the form has been submitted, set all data and save it
     if ($submit) {
         // Test if the form is valid
         // Use -1 to allow unlimited time to submit form
         if (!check_form_key('add_edit_page', -1)) {
             $errors[] = $this->user->lang('FORM_INVALID');
         }
         // Map the form's page data fields to setters
         $map_fields = array('set_title' => $data['page_title'], 'set_route' => $data['page_route'], 'set_description' => $data['page_description'], 'set_content' => $data['page_content'], 'set_template' => $data['page_template'], 'set_order' => $data['page_order'], 'set_page_display' => $data['page_display'], 'set_page_display_to_guests' => $data['page_display_to_guests']);
         // Set the mapped page data in the entity
         foreach ($map_fields as $entity_function => $page_data) {
             try {
                 // Calling the $entity_function on the entity and passing it $page_data
                 call_user_func_array(array($entity, $entity_function), array($page_data));
             } catch (\phpbb\pages\exception\base $e) {
                 // Catch exceptions and add them to errors array
                 $errors[] = $e->get_message($this->user);
             }
         }
         // Purge temporary variable
         unset($map_fields);
         // Insert or update page
         if (empty($errors)) {
             if ($entity->get_id()) {
                 // Save the edited page entity to the database
                 $entity->save();
                 // Save the page link location data
                 $this->page_operator->insert_page_links($entity->get_id(), $data['page_links']);
                 // Log the action
                 $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PAGES_EDITED_LOG', time(), array($entity->get_title()));
                 // Show user confirmation of the saved page and provide link back to the previous screen
                 trigger_error($this->user->lang('ACP_PAGES_EDIT_SUCCESS') . adm_back_link($this->u_action));
             } else {
                 // Add the new page entity to the database
                 /* @var $entity \phpbb\pages\entity\page */
                 $entity = $this->page_operator->add_page($entity);
                 // Save the page link location data (now that we can access the new id)
                 $this->page_operator->insert_page_links($entity->get_id(), $data['page_links']);
                 // Log the action
                 $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PAGES_ADDED_LOG', time(), array($entity->get_title()));
                 // Show user confirmation of the added page and provide link back to the previous screen
                 trigger_error($this->user->lang('ACP_PAGES_ADD_SUCCESS') . adm_back_link($this->u_action));
             }
         }
     }
     /**
      * Event to add to Pages ACP add/edit pages
      *
      * @event phpbb.pages.acp_add_edit_page
      * @since 1.0.0-RC1
      */
     $this->dispatcher->dispatch('phpbb.pages.acp_add_edit_page');
     // Set template vars for Page Template select menu
     $this->create_page_template_options($entity->get_template());
     // Set template vars for Page Link Locations select menu
     $this->create_page_link_options($entity->get_id(), $data['page_links']);
     // Set output vars for display in the template
     $this->template->assign_vars(array('S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'PAGES_TITLE' => $entity->get_title(), 'PAGES_ROUTE' => $entity->get_route(), 'PAGES_CONTENT' => $entity->get_content_for_edit(), 'PAGES_DESCRIPTION' => $entity->get_description(), 'PAGES_ORDER' => $entity->get_order(), 'S_PAGES_DISPLAY' => $entity->get_page_display(), 'S_PAGES_GUEST_DISPLAY' => $entity->get_page_display_to_guests(), 'S_PARSE_BBCODE_CHECKED' => $entity->content_bbcode_enabled(), 'S_PARSE_SMILIES_CHECKED' => $entity->content_smilies_enabled(), 'S_PARSE_MAGIC_URL_CHECKED' => $entity->content_magic_url_enabled(), 'S_PARSE_HTML_CHECKED' => $entity->content_html_enabled(), 'BBCODE_STATUS' => $this->user->lang('BBCODE_IS_ON', '<a href="' . append_sid("{$this->root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', '</a>'), 'SMILIES_STATUS' => $this->user->lang('SMILIES_ARE_ON'), 'IMG_STATUS' => $this->user->lang('IMAGES_ARE_ON'), 'FLASH_STATUS' => $this->user->lang('FLASH_IS_ON'), 'URL_STATUS' => $this->user->lang('URL_IS_ON'), 'S_BBCODE_ALLOWED' => true, 'S_SMILIES_ALLOWED' => true, 'S_BBCODE_IMG' => true, 'S_BBCODE_FLASH' => true, 'S_LINKS_ALLOWED' => true, 'U_BACK' => $this->u_action));
     // Build custom bbcodes array
     include_once $this->root_path . 'includes/functions_display.' . $this->php_ext;
     display_custom_bbcodes();
 }
Example #27
0
/**
* Prints out information about a user
* @param object $user current user
*/
function printUI(&$user)
{
    ?>
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
	<tr>
	  <td class="tableBorder">
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
          <tr> 
            <td class="rowHeaders" width="25%"><?php 
    echo translate('Name');
    ?>
</td>
            <td class="cellColor"><?php 
    echo $user->get_name();
    ?>
</td>
          </tr>
          <tr> 
            <td class="rowHeaders"><?php 
    echo translate('Member ID');
    ?>
</td>
            <td class="cellColor"><?php 
    echo $user->get_id();
    ?>
</td>
          </tr>
          <tr>
            <td class="rowHeaders"><?php 
    echo translate('Email');
    ?>
</td>
            <td class="cellColor"><?php 
    echo '<a href="mailto:' . $user->get_email() . '">' . $user->get_email() . '</a>';
    ?>
</td>
          </tr>
          <tr>
            <td class="rowHeaders"><?php 
    echo translate('Phone');
    ?>
</td>
            <td class="cellColor"><?php 
    echo $user->get_phone();
    ?>
</td>
          </tr>
          <tr>
            <td class="rowHeaders"><?php 
    echo translate('Institution');
    ?>
</td>
            <td class="cellColor"><?php 
    echo $user->get_inst();
    ?>
</td>
          </tr>
          <tr>
            <td class="rowHeaders"><?php 
    echo translate('Position');
    ?>
</td>
            <td class="cellColor"><?php 
    echo $user->get_position();
    ?>
</td>
          </tr>
          <tr>
            <td class="rowHeaders" valign="top"><?php 
    echo translate('Permissions');
    ?>
</td>
            <td class="cellColor">
				<?php 
    $perms = $user->get_perms();
    foreach ($perms as $machid => $name) {
        echo $name . '<br />';
    }
    ?>
</td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
<?php 
}
 /**
  * Generates the HTML to display this element
  *
  * @param object $f the field object
  * @return string
  */
 function html($f)
 {
     if (!ini_get('file_uploads')) {
         error('File uploads are disabled on this webserver.');
     }
     $max_filesize = ini_get('upload_max_filesize');
     $last = strtolower($max_filesize[strlen($max_filesize) - 1]);
     switch ($last) {
         case 'g':
             $max_filesize *= 1024;
         case 'm':
             $max_filesize *= 1024;
         case 'k':
             $max_filesize *= 1024;
     }
     $h = '';
     if (!$f->form->get_file_input_added()) {
         $f->form->set_file_input_added(TRUE);
         $h .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_filesize . '" ' . $f->get_xhtml_slash() . '>';
     }
     return $h . '<input type="file" id="' . $f->get_id() . '" name="' . $f->get_post_var_name() . '" ' . $f->get_extra_attribs() . ' ' . $f->get_xhtml_slash() . '>';
 }
Example #29
0
/**
 * Format admin settings
 *
 * @param object $setting
 * @param string $title label element
 * @param string $form form fragment, html code - not highlighted automatically
 * @param string $description
 * @param bool $label link label to id, true by default
 * @param string $warning warning text
 * @param sting $defaultinfo defaults info, null means nothing, '' is converted to "Empty" string, defaults to null
 * @param string $query search query to be highlighted
 * @return string XHTML
 */
function format_admin_setting($setting, $title = '', $form = '', $description = '', $label = true, $warning = '', $defaultinfo = NULL, $query = '')
{
    global $CFG;
    $name = empty($setting->plugin) ? $setting->name : "{$setting->plugin} | {$setting->name}";
    $fullname = $setting->get_full_name();
    // sometimes the id is not id_s_name, but id_s_name_m or something, and this does not validate
    if ($label) {
        $labelfor = 'for = "' . $setting->get_id() . '"';
    } else {
        $labelfor = '';
    }
    $override = '';
    if (empty($setting->plugin)) {
        if (array_key_exists($setting->name, $CFG->config_php_settings)) {
            $override = '<div class="form-overridden">' . get_string('configoverride', 'admin') . '</div>';
        }
    } else {
        if (array_key_exists($setting->plugin, $CFG->forced_plugin_settings) and array_key_exists($setting->name, $CFG->forced_plugin_settings[$setting->plugin])) {
            $override = '<div class="form-overridden">' . get_string('configoverride', 'admin') . '</div>';
        }
    }
    if ($warning !== '') {
        $warning = '<div class="form-warning">' . $warning . '</div>';
    }
    if (is_null($defaultinfo)) {
        $defaultinfo = '';
    } else {
        if ($defaultinfo === '') {
            $defaultinfo = get_string('emptysettingvalue', 'admin');
        }
        $defaultinfo = highlight($query, nl2br(s($defaultinfo)));
        $defaultinfo = '<div class="form-defaultinfo">' . get_string('defaultsettinginfo', 'admin', $defaultinfo) . '</div>';
    }
    $str = '
<div class="form-item clearfix" id="admin-' . $setting->name . '">
  <div class="form-label">
    <label ' . $labelfor . '>' . highlightfast($query, $title) . '<span class="form-shortname">' . highlightfast($query, $name) . '</span>
      ' . $override . $warning . '
    </label>
  </div>
  <div class="form-setting">' . $form . $defaultinfo . '</div>
  <div class="form-description">' . highlight($query, markdown_to_html($description)) . '</div>
</div>';
    $adminroot = admin_get_root();
    if (array_key_exists($fullname, $adminroot->errors)) {
        $str = '<fieldset class="error"><legend>' . $adminroot->errors[$fullname]->error . '</legend>' . $str . '</fieldset>';
    }
    return $str;
}
 /**
  * Called after a field of this type is deleted.
  * @param object $field the deleted WPBDP_FormField object.
  */
 public function cleanup(&$field)
 {
     if ($field->get_association() == 'meta') {
         global $wpdb;
         $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s", '_wpbdp[fields][' . $field->get_id() . ']'));
     }
 }