/**
  * Initiate query invoke command.
  * @param int
  * @return array
  */
 public function invoke($parameters = null)
 {
     list($setting_template_id) = $parameters;
     // Call query.
     $select_template = parent::invoke();
     // Set.
     $template_option_ = false;
     // Template list
     if (empty($select_template)) {
         $select_template = array();
     }
     foreach ($select_template as $select_template_array) {
         if ($setting_template_id == $select_template_array['template_id']) {
             $selected = 'selected';
         } else {
             $selected = '';
         }
         // Create template dropdown.
         $template_option_ .= '<option value="' . $select_template_array['template_id'] . '" ' . $selected . '>' . $select_template_array['template_folder'] . '</option>';
         $template_id_db[$select_template_array['template_id']] = $select_template_array['template_folder'];
     }
     if (!empty($template_option_)) {
         $template_option_ar['dropdown'] = $template_option_;
         $template_option_ar['selected'] = $template_id_db;
         return $template_option_ar;
     } else {
         return array();
     }
 }
 /**
  * Initiate query invoke command.
  * @param array
  * @return array
  */
 public function invoke($parameters = null)
 {
     // Define.
     $table_data = $parameters[0];
     $tables_ = '';
     $tables = '';
     $tables_to_optimize = '';
     // Fetch table data.
     foreach ($table_data as $table_name => $all_tables_array) {
         $tables = $table_name;
         $tables_ .= $tables . ',';
     }
     // Write DB string.
     $tables_to_optimize = rtrim($tables_, ',');
     // Query the database
     $optimize_results = parent::invoke($tables_to_optimize);
     // Print Results
     foreach ($optimize_results as $optimize_results_array) {
         $table = $optimize_results_array['Table'];
         $Op = $optimize_results_array['Op'];
         $msg_type = $optimize_results_array['Msg_type'];
         $msq_text = $optimize_results_array['Msg_text'];
         // This is used for template preview when debugging.
         $RESULTS[] = array('table' => $table, 'Op' => $Op, 'msg_type' => $msg_type, 'msq_text' => $msq_text);
     }
     if ($RESULTS) {
         return $RESULTS;
     } else {
         return false;
     }
 }
 /**
  * Initiate query invoke command.
  * @param string
  */
 public function invoke($parameters = null)
 {
     $file_id = $parameters[0];
     $deleted_filelog = $this->db->deleteQuick('_db_core_upload_logs', 'file_id', $file_id, 'original_filename');
     if ($deleted_filelog) {
         // Loop and delete.
         $delete_farr = parent::invoke(array($file_id));
         // Start deleting.
         $path_to_delete = $this->configuration['absolute_path'] . $delete_farr['relative_path'] . $delete_farr['new_filename'];
         if (is_writable($path_to_delete)) {
             unlink($path_to_delete);
         }
         $path_to_delete = $this->configuration['absolute_path'] . $delete_farr['resized'];
         if (is_writable($path_to_delete)) {
             unlink($path_to_delete);
         }
         $path_to_delete = $this->configuration['absolute_path'] . $delete_farr['thumbnail'];
         if (is_writable($path_to_delete)) {
             unlink($path_to_delete);
         }
         $this->template->ok(sprintf(_('File %s was deleted.'), $deleted_filelog));
     } else {
         $this->template->warning(sprintf(_('No file "%s" to delete.'), $this->security->get['df']));
     }
 }
 public function invoke($parameters = null)
 {
     $s = $this->security->post;
     $write_sd = '';
     if (!empty($s['class_name_'])) {
         $write_sd .= "('', '{$s['class_name_']}', '{$s['alias_']}', '{$s['plugin_folder_']}', 1, '{$s['rank_']}'),";
     }
     if (!empty($s['class_id'])) {
         foreach ($s['class_id'] as $sd) {
             if (!empty($sd)) {
                 $write_sd .= "('{$sd}', '{$s['class_name'][$sd]}', '{$s['alias'][$sd]}', '{$s['plugin_folder'][$sd]}', {$s['enable'][$sd]}, '{$s['rank'][$sd]}'),";
             } else {
                 $this->template->warning(__('You must provide all fields to identify the class'));
                 break;
             }
         }
     }
     if (!empty($write_sd)) {
         $write_sd = rtrim($write_sd, ',');
         if (parent::invoke(array($write_sd))) {
             $this->template->ok(__('Class changes were saved.'));
         }
     } else {
         $this->template->warning(__('No class data was changed.'));
     }
 }
 /**
  * Initiate query invoke command.
  * @return array
  */
 public function invoke($parameters = null)
 {
     $query_user_roles = parent::invoke();
     $user_roles_info = '';
     if (empty($query_user_roles)) {
         $query_user_roles = array();
     }
     foreach ($query_user_roles as $query_user_roles_array) {
         $user_roles_info .= '[' . $query_user_roles_array['user_role_id'] . '&#61;&#62;' . $query_user_roles_array['user_role_name'] . '] ';
         $user_role_description[$query_user_roles_array['user_role_id']] = $query_user_roles_array['user_role_name'];
     }
     // Select all permissions.
     $select_role_permission = $this->db->invokeQuery('PHPDS_getRolePermissionsQuery');
     // Assign permissions array.
     if (empty($select_role_permission)) {
         $select_role_permission = array();
     }
     foreach ($select_role_permission as $select_role_permission_array) {
         $user_role_id = $select_role_permission_array['user_role_id'];
         $node_id = $select_role_permission_array['node_id'];
         // Define.
         if (empty($permissions[$node_id])) {
             $permissions[$node_id] = false;
         }
         if (empty($user_role_field_info[$node_id])) {
             $user_role_field_info[$node_id] = false;
         }
         if (empty($user_role_description[$user_role_id])) {
             $user_role_description[$user_role_id] = false;
         }
         $permissions[$node_id] .= $user_role_id . ',';
         $user_role_field_info[$node_id] .= "[" . $user_role_id . '&#61;&#62;' . $user_role_description[$user_role_id] . "] ";
     }
     return array(rtrim($user_roles_info, ","), $permissions, $user_role_field_info);
 }
 public function invoke($parameters = null)
 {
     list($object, $target, $taggernames, $taggervalues, $taggerids, $taggerdeletes) = $parameters;
     if (!empty($target) && !empty($object)) {
         foreach ($taggernames as $key => $name) {
             if (!empty($name)) {
                 $id = !empty($taggerids[$key]) ? $taggerids[$key] : '';
                 $value = !empty($taggervalues[$key]) ? $taggervalues[$key] : '';
                 $tag[] = array($id, $object, $name, $target, $value);
             }
         }
         if (!empty($taggerdeletes)) {
             foreach ($taggerdeletes as $name_) {
                 $this->db->invokeQuery('PHPDS_deleteStrictTagsQuery', $object, $target, $name_);
             }
         }
         if (!empty($tag)) {
             $datarows = $this->rows($tag);
         }
         if (!empty($datarows)) {
             return parent::invoke(array($datarows));
         } else {
             return array();
         }
     }
 }
 /**
  * Initiate query invoke command.
  */
 public function invoke($parameters = null)
 {
     // Update tags.
     $write_tag = '';
     $t = $this->security->post;
     // Execute saving new tag.
     if (!empty($t['tagObject'][0])) {
         if (!empty($t['tagName'][0]) && !empty($t['tagTarget'][0])) {
             $write_tag .= "('', '{$t['tagObject'][0]}', '{$t['tagName'][0]}', '{$t['tagTarget'][0]}', '{$t['tagValue'][0]}'),";
         } else {
             $this->template->warning(__('To add a new tag please provide both Tag Name and Tag Target.'));
         }
     }
     // We dont need you anymore, go rest somewhere.
     unset($t['tagObject'][0]);
     // Execute updating rows.
     if (is_array($t['tagObject'])) {
         foreach ($t['tagObject'] as $id => $tag) {
             if (empty($tag) || empty($t['tagName'][$id]) || empty($t['tagTarget'][$id])) {
                 $this->template->warning(sprintf(__('Nothing saved, you missed tag values for tag id %u.'), $id));
                 break;
             }
             $write_tag .= "('{$id}', '{$tag}', '{$t['tagName'][$id]}', '{$t['tagTarget'][$id]}', '{$t['tagValue'][$id]}'),";
         }
     }
     if (!empty($write_tag)) {
         $write_tag = rtrim($write_tag, ',');
         $this->template->ok(__('Tags updated.'));
         return parent::invoke(array($write_tag));
     } else {
         return false;
     }
 }
Example #8
0
 /**
  * Initiate query invoke command.
  * @param int
  * @return array
  */
 public function invoke($parameters = null)
 {
     // Delete all logs.
     parent::invoke();
     // Reset auto increment counter.
     $this->db->invokeQuery('PHPDS_resetSystemLogsQuery');
     $this->template->ok(_('Logs table cleared.'));
 }
 public function invoke($parameters = null)
 {
     if (!empty($_COOKIE['pdspc'])) {
         $user_id = $parameters[0];
         $id_crypt = substr($_COOKIE['pdspc'], 0, 6);
         parent::invoke(array($id_crypt, $user_id));
         return setcookie('pdspc', 'false', 0);
     }
 }
Example #10
0
 /**
  * Initiate invoke query.
  */
 public function invoke($parameters = null)
 {
     list($query_grouped, $file_id, $order, $limit) = $parameters;
     if (empty($file_id)) {
         // Create order and limit query.
         $order_by = " ORDER BY {$order} LIMIT {$limit}";
     } else {
         $order_by = '';
     }
     return parent::invoke(array($query_grouped, $order_by));
 }
 /**
  * Initiate query invoke command.
  * @return array
  */
 public function invoke($parameters = null)
 {
     $select_template = parent::invoke();
     if (empty($select_template)) {
         $select_template = array();
     }
     foreach ($select_template as $select_template_array) {
         $template_option[$select_template_array['template_id']] = $select_template_array['template_folder'];
     }
     return $template_option;
 }
 public function invoke($parameters = null)
 {
     $user_group_id = $parameters[0];
     $user_groups_db = parent::invoke();
     $user_groups_option_move = '';
     if (empty($user_groups_db)) {
         $user_groups_db = array();
     }
     foreach ($user_groups_db as $user_groups_array) {
         // Check selected.
         $user_groups_array['user_group_id'] == $user_group_id ? $moved_group_selected = 'selected' : ($moved_group_selected = '');
         $user_groups_option_move .= '<option value="' . $user_groups_array['user_group_id'] . '" ' . $moved_group_selected . '>' . $user_groups_array['user_group_name'] . '</option>';
     }
     return $user_groups_option_move;
 }
Example #13
0
 public function invoke($parameters = null)
 {
     list($val, $join_id_col, $join_id, $value_col, $array) = $parameters;
     $this->db->deleteQuick('_db_' . $val, $join_id_col, $join_id);
     if (!empty($array)) {
         $rows = '';
         foreach ($array as $value) {
             $rows .= "({$join_id}, {$value}),";
         }
         if (!empty($rows)) {
             $rows = rtrim($rows, ",");
             parent::invoke(array($val, $join_id_col, $value_col, $rows));
         }
     }
 }
 /**
  * Initiate query invoke command.
  * @param int
  * @return array
  */
 public function invoke($parameters = null)
 {
     // Get actual query.
     $this->sql = preg_replace("/select/i", 'SELECT SQL_CALC_FOUND_ROWS', $parameters[0], 1);
     if (!empty($parameters[1])) {
         $param = $parameters[1];
     } else {
         $param = array();
     }
     $results = parent::invoke($param);
     if (!empty($results)) {
         return $results;
     } else {
         return array();
     }
 }
Example #15
0
 /**
  * Initiate query invoke command.
  * @param int
  * @return array
  */
 public function invoke($parameters = null)
 {
     $menu_id = $parameters[0];
     // Do we need only a single menu id item?
     if (!empty($menu_id)) {
         $WHERE = " WHERE t1.menu_id = '{$menu_id}' ";
     } else {
         $WHERE = '';
     }
     $menu = parent::invoke(array($WHERE));
     if (!empty($menu)) {
         return $menu;
     } else {
         return array();
     }
 }
Example #16
0
 /**
  * Initiate query invoke command.
  * @param int
  * @return array
  */
 public function invoke($parameters = null)
 {
     $node_id = $parameters[0];
     // Do we need only a single node id item?
     if (!empty($node_id)) {
         $WHERE = " WHERE t1.node_id = '{$node_id}' ";
     } else {
         $WHERE = '';
     }
     $node = parent::invoke(array($WHERE));
     if (!empty($node)) {
         return $node;
     } else {
         return array();
     }
 }
 /**
  * Initiate query invoke command.
  * @param int
  * @return array
  */
 public function invoke($parameters = null)
 {
     $plugin_record_db = parent::invoke();
     // Compile results and save into array to compare against user selected options and already installed plugins.
     if (empty($plugin_record_db)) {
         $plugin_record_db = array();
     }
     foreach ($plugin_record_db as $plugin_record_array) {
         $activation_db[$plugin_record_array['plugin_folder']] = array('status' => $plugin_record_array['status'], 'version' => $plugin_record_array['version'], 'use_logo' => $plugin_record_array['use_logo']);
     }
     if (!empty($activation_db)) {
         return $activation_db;
     } else {
         return array();
     }
 }
Example #18
0
 /**
  * Loads array of log messages.
  * @param int $limit_messages
  * @return array
  */
 public function invoke($parameters = null)
 {
     // create the parameter list for the query
     // we add an argument there, otherwise we could just pass the parameters to the query() method
     $limit_messages = $parameters[0];
     $parameters = array($this->configuration['user_id'], $limit_messages);
     $template = $this->template;
     // send the actual query to the database
     $log_enties = parent::invoke($parameters);
     if (!empty($log_enties)) {
         // ok now the real job, the data is here, no DB-related stuff anymore
         $message_ = array();
         foreach ($log_enties as $get_logs_array) {
             $log_type = $get_logs_array['log_type'];
             $log_description = $get_logs_array['log_description'];
             $log_time = $this->core->formatTimeDate($get_logs_array['log_time']);
             // Set messages in correct categories.
             switch ($log_type) {
                 // Ok.
                 case 1:
                     $message_[] = array('description' => $template->mod->ok($log_description), 'log_time' => $log_time);
                     break;
                     // Warning.
                 // Warning.
                 case 2:
                     $message_[] = array('description' => $template->mod->warning($log_description), 'log_time' => $log_time);
                     break;
                     // Critical.
                 // Critical.
                 case 3:
                     $message_[] = array('description' => $template->mod->critical($log_description), 'log_time' => $log_time);
                     break;
             }
         }
     }
     if (!empty($message_)) {
         return $message_;
     } else {
         return false;
     }
 }
Example #19
0
    /**
     * Initiate query invoke command.
     * @param int
     * @return string
     */
    public function invoke($parameters = null)
    {
        $select_registration_tokens = parent::invoke();
        // Set.
        $registration_selection = false;
        // Fetch results and create token options..
        if (empty($select_registration_tokens)) {
            $select_registration_tokens = array();
        }
        foreach ($select_registration_tokens as $reg_tokens_array) {
            // Check if we should list this as an item.
            $registration_selection .= <<<HTML
\t\t\t\t<option value="{$reg_tokens_array['token_id']}">
\t\t\t\t\t {$reg_tokens_array['token_name']}
\t\t\t\t</option>
HTML;
        }
        if (!empty($registration_selection)) {
            return $registration_selection;
        } else {
            return '';
        }
    }
 public function invoke($parameters = null)
 {
     $s = $this->security->post;
     // Write new setting.
     $write_sd = '';
     if (!empty($s['setting_description_'])) {
         $write_sd .= "('{$s['setting_description_']}', '{$s['setting_value_']}', '{$s['note_']}'),";
     }
     // Write everything else.
     if (!empty($s['setting_description'])) {
         foreach ($s['setting_description'] as $sd) {
             if (!empty($sd)) {
                 if (empty($s['setting_value'][$sd])) {
                     $s['setting_value'][$sd] = '';
                 }
                 if (empty($s['note'][$sd])) {
                     $s['note'][$sd] = '';
                 }
                 $write_sd .= "('{$sd}', '{$s['setting_value'][$sd]}', '{$s['note'][$sd]}'),";
             } else {
                 $this->template->warning(_('You must provide a field name to identify the setting by.'));
                 break;
             }
         }
     }
     // Do we have anything to write to database.
     if (!empty($write_sd)) {
         // Prepare write.
         $write_sd = rtrim($write_sd, ',');
         // Write to DB.
         if (parent::invoke(array($write_sd))) {
             $this->template->ok(_('Plugin settings was saved.'));
         }
     } else {
         $this->template->warning(_('No plugin settings was saved.'));
     }
 }
 public function invoke($parameters = null)
 {
     $all_user_roles = $parameters[0];
     if (empty($all_user_roles)) {
         throw new PHPDS_Exception('Cannot extract nodes when no roles are given.');
     }
     $select_nodes = parent::invoke($all_user_roles);
     $navigation = $this->navigation;
     $aburl = $this->configuration['absolute_url'];
     $sef = !empty($this->configuration['sef_url']);
     //$append = ! empty($this->configuration['url_append']);
     $append = $this->configuration['url_append'];
     $charset = $this->core->mangleCharset($this->charset());
     $father = $this->PHPDS_dependance();
     foreach ($select_nodes as $mr) {
         ////////////////////////
         // Create node items. //
         ////////////////////////
         $new_node = array();
         $father->copyArray($mr, $new_node, array('node_id', 'parent_node_id', 'alias', 'node_link', 'rank', 'hide', 'new_window', 'is_parent', 'type', 'template_folder', 'layout', 'plugin', 'node_type', 'extend'));
         $new_node['node_name'] = $navigation->determineNodeName($mr['node_name'], $mr['node_link'], $mr['node_id'], $mr['plugin']);
         $new_node['params'] = !empty($mr['params']) ? html_entity_decode($mr['params'], ENT_COMPAT, $charset) : '';
         $new_node['plugin_folder'] = 'plugins/' . $mr['plugin'] . '/';
         if ($sef && !empty($mr['alias'])) {
             $navigation->navAlias[$mr['alias']] = $mr['node_type'] != PHPDS_navigation::node_jumpto_link ? $mr['node_id'] : $mr['extend'];
             $new_node['href'] = $aburl . '/' . $mr['alias'] . $append;
         } else {
             $new_node['href'] = $aburl . '/index.php?m=' . ($mr['node_type'] != PHPDS_navigation::node_jumpto_link ? $mr['node_id'] : $mr['extend']);
         }
         // Writing children for single level dropdown.
         if (!empty($mr['parent_node_id'])) {
             $navigation->child[$mr['parent_node_id']][] = $mr['node_id'];
         }
         $navigation->navigation[$mr['node_id']] = $new_node;
     }
 }
Example #22
0
 /**
  * Initiate query invoke command.
  * @param array
  * @return array
  */
 public function invoke($parameters = null)
 {
     list($user_id, $user_role) = $parameters;
     // We need to check what user role this user belongs to.
     // This user belongs to root role, so it is safe to allow.
     if ($this->user->isRoot($user_id)) {
         return true;
     }
     // Check if we have a user id.
     if (empty($user_id)) {
         // Use default id.
         !empty($this->configuration['user_id']) ? $user_id = $this->configuration['user_id'] : ($user_id = false);
     }
     // First lets query if this user belongs to given role.
     $check_user_in_role_db = parent::invoke(array($user_role, $user_role, $user_id, $user_id));
     // Lets check if this user exists.
     if ($check_user_in_role_db['user_id'] == $user_id) {
         return true;
     } else {
         return false;
     }
 }
Example #23
0
 /**
  * Initiate query invoke command.
  * @param array
  * @return array
  */
 public function invoke($parameters = null)
 {
     // Get installed plugins with cache.
     if ($this->db->cacheEmpty('plugins_installed')) {
         // Query installed plugins.
         $installed_plugins_db = parent::invoke();
         // Loop array.
         // $plugins_installed = array();
         foreach ($installed_plugins_db as $installed_plugins_array) {
             $plugins_installed[$installed_plugins_array['plugin_folder']] = array('plugin_folder' => $installed_plugins_array['plugin_folder'], 'status' => $installed_plugins_array['status'], 'version' => $installed_plugins_array['version'], 'use_logo' => $installed_plugins_array['use_logo']);
             // Set plugin logo as well.
             if ($installed_plugins_array['use_logo']) {
                 $plugin_logo = $installed_plugins_array['plugin_folder'];
             }
         }
         $this->db->pluginsInstalled = $plugins_installed;
         if (empty($plugin_logo)) {
             $plugin_logo = '';
         }
         $this->db->pluginLogo = $plugin_logo;
         // Write essential plugin data to cache.
         $this->db->cacheWrite('plugins_installed', $plugins_installed);
         $this->db->cacheWrite('plugin_logo', $plugin_logo);
     } else {
         // Read installed plugins from cache.
         $this->db->pluginsInstalled = $this->db->cacheRead('plugins_installed');
         $this->db->pluginLogo = $this->db->cacheRead('plugin_logo');
     }
 }
Example #24
0
 public function invoke($parameters = null)
 {
     if ($this->db->cacheEmpty('plugins_installed')) {
         $installed_plugins_db = parent::invoke();
         foreach ($installed_plugins_db as $installed_plugins_array) {
             $plugins_installed[$installed_plugins_array['plugin_folder']] = array('plugin_folder' => $installed_plugins_array['plugin_folder'], 'status' => $installed_plugins_array['status'], 'version' => $installed_plugins_array['version'], 'use_logo' => $installed_plugins_array['use_logo']);
             if ($installed_plugins_array['use_logo']) {
                 $plugin_logo = $installed_plugins_array['plugin_folder'];
             }
         }
         $this->db->pluginsInstalled = $plugins_installed;
         if (empty($plugin_logo)) {
             $plugin_logo = '';
         }
         $this->db->pluginLogo = $plugin_logo;
         $this->db->cacheWrite('plugins_installed', $plugins_installed);
         $this->db->cacheWrite('plugin_logo', $plugin_logo);
     } else {
         $this->db->pluginsInstalled = $this->db->cacheRead('plugins_installed');
         $this->db->pluginLogo = $this->db->cacheRead('plugin_logo');
     }
 }
    /**
     * Initiate query invoke command.
     * @param int
     * @return array
     */
    public function invoke($parameters = null)
    {
        // Set parameters
        $select_tokens = parent::invoke($parameters);
        // Fetch results and create token options..
        $token_selection = '';
        $edit['token_id_option'] = '';
        if (!empty($select_tokens)) {
            foreach ($select_tokens as $tokens_array) {
                // Is token selected.
                $tokens_array['token_id'] == $edit['token_id_option'] ? $token_selected = 'selected' : ($token_selected = false);
                // Check if we should list this as an item.
                $token_selection .= <<<HTML
\t\t\t\t\t<option value="{$tokens_array['token_id']}" {$token_selected}>
\t\t\t\t\t\t{$tokens_array['token_name']} (Role: {$tokens_array['user_role_name']}) (Group: {$tokens_array['user_group_name']})
\t\t\t\t\t</option>"
HTML;
            }
            return $token_selection;
        } else {
            return '';
        }
    }
 /**
  * Initiate query invoke command.
  * @param array
  * @return array
  */
 public function invoke($parameters = null)
 {
     $edit = $parameters[0];
     $select_template = parent::invoke();
     if (empty($edit['template_id'])) {
         $edit['template_id'] = $this->configuration['default_template_id'];
     }
     // Define.
     $template_option_ = false;
     // Loop template options.
     if (empty($select_template)) {
         $select_template = array();
     }
     foreach ($select_template as $select_template_array) {
         // Check if if item should be selected.
         $select_template_array['template_id'] == $edit['template_id'] ? $template_selected = 'selected' : ($template_selected = false);
         $template_option_ .= '<option value="' . $select_template_array['template_id'] . '" ' . $template_selected . '>' . $select_template_array['template_folder'] . '</option>';
     }
     return array('edit' => $edit, 'template_option_' => $template_option_);
 }
Example #27
0
 /**
  * Initiate query invoke command.
  */
 public function invoke($parameters = null)
 {
     list($object, $target, $value_original, $names) = $parameters;
     if (!empty($target)) {
         // Lets just clean up old tags before we save.
         if (!empty($names)) {
             $new_tags_array = explode("\r\n", $names);
             $new_tags = '';
             foreach ($new_tags_array as $tags) {
                 $tags = trim($tags);
                 $value = trim($value_original);
                 $splittags = strpos($tags, ":");
                 if (!empty($splittags)) {
                     list($tags, $value) = explode(":", $tags);
                     if (empty($value)) {
                         $value = trim($value_original);
                     }
                 }
                 $new_tags .= "('', '{$object}', '{$tags}', '{$target}', '{$value}'),";
             }
             if (!empty($new_tags)) {
                 $new_tags = rtrim($new_tags, ",");
                 return parent::invoke(array($new_tags));
             }
         } else {
             return false;
         }
     }
 }
 public function invoke($parameters = null)
 {
     list($user_id, $user_group) = $parameters;
     if ($this->user->isRoot($user_id)) {
         return true;
     }
     if (empty($user_id)) {
         !empty($this->configuration['user_id']) ? $user_id = $this->configuration['user_id'] : ($user_id = null);
     }
     $check_user_in_group_db = parent::invoke(array($user_group, $user_id));
     if ($check_user_in_group_db['user_id'] == $user_id) {
         return true;
     } else {
         return false;
     }
 }
 public function invoke($parameters = null)
 {
     list($user_id, $roles) = $parameters;
     if (!is_array($roles)) {
         $roles = array($roles);
     }
     foreach ($roles as $role) {
         parent::invoke(array('user_id' => $user_id, 'user_role_id' => $role));
     }
     return true;
 }
Example #30
0
 /**
  * Initiate query invoke command.
  * @param array
  * @return array
  */
 public function invoke($parameters = null)
 {
     $cronjobs_list_db = parent::invoke();
     // Set current server timestamp.
     $current_server_timestamp = time();
     // Loop results to check which crons should run on this cycle and which should be skipped.
     if (empty($cronjobs_list_db)) {
         $cronjobs_list_db = array();
     }
     foreach ($cronjobs_list_db as $cronjobs_array) {
         // Assign cronjob variables.
         $cron_ = $cronjobs_array;
         // Check if we have the plugin folder.
         if (!empty($this->navigation->navigation[$cron_['node_id']]['plugin_folder'])) {
             // Assign plugin folder.
             $plugin_folder = $this->navigation->navigation[$cron_['node_id']]['plugin_folder'];
         } else {
             // Assign error handling and message.
             $error[1] = true;
             $this->template->critical(sprintf(__('Cronjob %s (%s) - FAILED - No plugin found for cron node item. Also check access rights for this cron.'), $this->navigation->navigation[$cron_['node_id']]['node_name'], "({$cron_['node_id']})"));
         }
         // Check if we have the cron link.
         if (!empty($this->navigation->navigation[$cron_['node_id']]['node_link'])) {
             // Assign link.
             $node_link = $this->navigation->navigation[$cron_['node_id']]['node_link'];
         } else {
             // Assign error handling and message.
             $error[2] = true;
             $this->template->critical(sprintf(__('Cronjob %s (%s) - FAILED - No link found for cron node item.'), $this->navigation->navigation[$cron_['node_id']]['node_name'], "({$cron_['node_id']})"));
         }
         if (empty($error)) {
             // Log cron if required.
             $cron_['log_cron'] == 1 ? $log_cron = true : ($log_cron = false);
             // Start handling cronjobs by type.
             switch ($cron_['cron_type']) {
                 case 0:
                     // Skip Cron.
                     $execute_cron = false;
                     break;
                 case 1:
                     // Calculate once of date.
                     $execute_on_date = mktime("{$cron_['hour']}", "{$cron_['minute']}", 0, "{$cron_['month']}", "{$cron_['day']}", "{$cron_['year']}");
                     // Check if item should run.
                     if ($current_server_timestamp >= $execute_on_date) {
                         // Execute Cron.
                         $execute_cron = true;
                         // Disable Cron.
                         $update_cron_type = ', cron_type = 0';
                     } else {
                         // Skip Cron.
                         $execute_cron = false;
                         // Dont Disable Cron.
                         $update_cron_type = '';
                     }
                     break;
                 case 2:
                     // Dont Disable Cron.
                     $update_cron_type = false;
                     // Calculate seconds.
                     $year_in_seconds = $cron_['year'] * 31556926;
                     $month_in_seconds = $cron_['month'] * 2629743.83;
                     $day_in_seconds = $cron_['day'] * 86400;
                     $hour_in_seconds = $cron_['hour'] * 3600;
                     $minute_in_seconds = $cron_['minute'] * 60;
                     // Total seconds.
                     $sec_intervals = $year_in_seconds + $month_in_seconds + $day_in_seconds + $hour_in_seconds + $minute_in_seconds;
                     // Check if cron should execute on this cycle.
                     if ($current_server_timestamp - $cron_['last_execution'] >= $sec_intervals) {
                         // Execute Cron.
                         $execute_cron = true;
                     } else {
                         // Skip Cron.
                         $execute_cron = false;
                     }
                     break;
                 default:
                     // Skip Cron.
                     $execute_cron = false;
                     break;
             }
         }
         // Continue executing cron if required.
         if ($execute_cron == true) {
             // Inlude script.
             // Measure execution time.
             $time = microtime();
             $time = explode(' ', $time);
             $time = $time[1] + $time[0];
             $start = $time;
             // Update Cron Runtime.
             $this->db->invokeQuery('PHPDS_updateExeCronQuery', $current_server_timestamp, $update_cron_type, $cron_['node_id']);
             if ($this->core->loadControllerFile($cron_['node_id'], true)) {
                 // Lets tell the autoloader where he could also look for a class.
                 if (!empty($plugin_folder)) {
                     $this->configuration['plugin_alt'] = $plugin_folder;
                 }
                 // Ok we do not plugin_alt anymore.
                 $this->configuration['plugin_alt'] = false;
                 // Do not output any HTML var.
                 $HTML = false;
                 // Measure execution time.
                 $time = microtime();
                 $time = explode(' ', $time);
                 $time = $time[1] + $time[0];
                 $finish = $time;
                 $total_time = round($finish - $start, 4);
                 // Output for debug.
                 $this->template->ok(sprintf(__('Cronjob %s - EXECUTED taking %s seconds.'), $this->navigation->navigation[$cron_['node_id']]['node_name'], $total_time), false, $log_cron);
             } else {
                 // Output for debug.
                 $this->template->critical(sprintf(__('Cronjob %s - FAILED - Could not locate/read file (%s), check if your permissions for cron is set to guest or if the file is readable and exists.'), $this->navigation->navigation[$cron_['node_id']]['node_name'], $node_link), false, $log_cron);
             }
         } else {
             // Output for debug.
             $this->template->notice(sprintf(__('Cronjob %s - SKIPPED!'), $this->navigation->navigation[$cron_['node_id']]['node_name']));
         }
         // Unset values that can be duplicated.
         unset($update_cron_type, $plugin_folder, $node_link);
     }
 }