예제 #1
0
    /**
     * Update the IWdocmanager module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {
        $table = DBUtil::getTables();
        switch ($oldversion) {
            case '0.0.1';
                $table = DBUtil::getTables();
                $c = $table['IWdocmanager_column'];
                $c1 = $table['IWdocmanager_categories_column'];
                // used in agora module upgrade in order to calc the number of document in each category
                $categories = DBUtil::selectObjectArray('IWdocmanager_categories', '', '', '-1', '-1', 'categoryId');
                foreach ($categories as $category) {
                    $where = "$c[categoryId] = $category[categoryId] AND $c[validated] = 1 AND $c[versioned] <= 0";
                    $number = DBUtil::selectObjectCount('IWdocmanager', $where);

                    $where = "$c[categoryId] = $category[categoryId] AND $c[validated] = 0 AND $c[versioned] <= 0";
                    $number1 = DBUtil::selectObjectCount('IWdocmanager', $where);
                    
                    $where = "$c1[categoryId] = $category[categoryId]";
                    $item = array('nDocuments' => $number,
                        'nDocumentsNV' => $number1
                    );

                    DBUtil::updateObject($item, 'IWdocmanager_categories', $where);
                }
            case '1.0.0':
            // future versions
        }
        return true;
    }
예제 #2
0
    /**
     * Gets all the items created in the menu
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:	args   id_parent
     * @return:	And array with the items information
     */
    public function getall($args) {
        // Security check
        if (!SecurityUtil::checkPermission('IWmenu::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        extract($args);

        // Needed arguments.
        if (isset($id_parent))
            $id = $id_parent;

        (!isset($id)) ? $id_parent = 0 : $id_parent = $id;

        $active = (isset($active)) ? " AND active=$active " : "";

        $pntable = DBUtil::getTables();
        $c = $pntable['IWmenu_column'];
        $where = ($id_parent == '-1') ? "$active" : "$c[id_parent]=$id_parent $active";

        $orderby = "$c[iorder]";

        // get the objects from the db
        $items = DBUtil::selectObjectArray('IWmenu', $where, $orderby, '-1', '-1', 'mid');

        // Check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($items === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }

        // Return the items
        return $items;
    }
예제 #3
0
파일: User.php 프로젝트: rmaiwald/Scribite
 public function getModuleConfig($args)
 {
     if (!isset($args['modulename'])) {
         $args['modulename'] = ModUtil::getName();
     }
     $modconfig = array();
     if ($args['modulename'] == 'list') {
         $modconfig = DBUtil::selectObjectArray('scribite', '', 'modname');
     } else {
         $dbtables = DBUtil::getTables();
         $scribitecolumn = $dbtables['scribite_column'];
         $where = "{$scribitecolumn['modname']} = '" . $args['modulename'] . "'";
         $item = DBUtil::selectObjectArray('scribite', $where);
         if ($item == false) {
             return;
         }
         $modconfig['mid'] = $item[0]['mid'];
         $modconfig['modulename'] = $item[0]['modname'];
         if (!is_int($item[0]['modfuncs'])) {
             $modconfig['modfuncs'] = unserialize($item[0]['modfuncs']);
         }
         if (!is_int($item[0]['modareas'])) {
             $modconfig['modareas'] = unserialize($item[0]['modareas']);
         }
         $modconfig['modeditor'] = $item[0]['modeditor'];
     }
     return $modconfig;
 }
예제 #4
0
 /**
  * Search
  *
  * do the actual search and display the results
  *
  * @return output the search results
  */
 public function search($args)
 {
     if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_READ)) {
         return true;
     }
     $minlen = 3;
     $maxlen = 30;
     if (strlen($args['q']) < $minlen || strlen($args['q']) > $maxlen) {
         return LogUtil::registerStatus($this->__f('The comments can only be searched for words that are longer than %1$s and less than %2$s characters!', array($minlen, $maxlen)));
     }
     ModUtil::dbInfoLoad('Search');
     $tables = DBUtil::getTables();
     // ezcomments tables
     $ezcommentstable = $tables['EZComments'];
     $ezcommentscolumn = $tables['EZComments_column'];
     // our own tables
     $searchTable = $tables['search_result'];
     $searchColumn = $tables['search_result_column'];
     // where
     $where = Search_Api_User::construct_where($args, array($ezcommentscolumn['subject'], $ezcommentscolumn['comment']));
     $where .= " AND " . $ezcommentscolumn['url'] . " != ''";
     $sessionId = session_id();
     $insertSql = "INSERT INTO {$searchTable}\n              ({$searchColumn['title']},\n               {$searchColumn['text']},\n               {$searchColumn['extra']},\n               {$searchColumn['module']},\n               {$searchColumn['created']},\n               {$searchColumn['session']})\n            VALUES\n            ";
     $comments = DBUtil::selectObjectArray('EZComments', $where);
     foreach ($comments as $comment) {
         $sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($comment['subject']) . '\', ' . '\'' . DataUtil::formatForStore($comment['comment']) . '\', ' . '\'' . DataUtil::formatForStore($comment['url']) . '\', ' . '\'' . 'EZComments' . '\', ' . '\'' . DataUtil::formatForStore($comment['date']) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
         $insertResult = DBUtil::executeSQL($sql);
         if (!$insertResult) {
             return LogUtil::registerError($this->__('Error! Could not load items.'));
         }
     }
     return true;
 }
예제 #5
0
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * Return all the references that have been created
     *
     * @param    int     $args['starnum']    (optional) first item to return
     * @param    int     $args['numitems']   (optional) number if items to return
     * @return   array   array of items, or false on failure
     */
    public function getall($args) {
        $items = array();

        // Security check
        if (!SecurityUtil::checkPermission('IWwebbox::', '::', ACCESS_ADMIN)) {
            return $items;
        }

        // Optional arguments.
        if (!isset($args['startnum']) || !is_numeric($args['startnum'])) {
            $args['startnum'] = 1;
        }

        if (!isset($args['numitems']) || !is_numeric($args['numitems'])) {
            $args['numitems'] = -1;
        }

        // get the objects from the db
        $items = DBUtil::selectObjectArray('IWwebbox', '', 'ref', $args['startnum'] - 1, $args['numitems'], '', '', '');

        // Check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($items === false) {
            return LogUtil::registerError(__('Error! Could not load items.'));
        }

        // Return the items
        return $items;
    }
예제 #6
0
파일: User.php 프로젝트: projectesIF/Sirius
    public function get_sense_grup() {

        $users = DBUtil::selectObjectArray('users', '', '', -1, -1, 'uid');
        // Check for a DB error
        if ($users === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }
        // get all users that are in any group
        $allUsersWithGroup = DBUtil::selectObjectArray('group_membership', '', '', -1, -1, 'uid');
        if ($allUsersWithGroup === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }
        $diff = array_diff_key($users, $allUsersWithGroup);
        $usersList = '$$';
        $registres = array();
        if (count($diff) > 0) {
            foreach ($diff as $user) {
                $usersList .= $user['uid'] . '$$';
            }
            //get all users information
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $usersInfo = ModUtil::func('IWmain', 'user', 'getAllUsersInfo', array('sv' => $sv,
                        'list' => $usersList,
                        'info' => 'ccn'));
            foreach ($usersInfo as $key => $value) {
                $registres[] = array('name' => $value,
                    'id' => $key);
            }
        }
        return $registres;
    }
예제 #7
0
 /**
  * Update attributes of a block.
  *
  * @param int $args ['bid'] the ID of the block to update.
  * @param string $args ['title'] the new title of the block.
  * @param string $args ['description'] the new description of the block.
  * @param string $args ['positions'] the new positions of the block.
  * @param string $args ['url'] the new URL of the block.
  * @param string $args ['language'] the new language of the block.
  * @param string $args ['content'] the new content of the block.
  *
  * @return bool true on success, false on failure.
  */
 public function update($args)
 {
     // Optional arguments
     if (!isset($args['url'])) {
         $args['url'] = '';
     }
     if (!isset($args['content'])) {
         $args['content'] = '';
     }
     // Argument check
     if (!isset($args['bid']) || !is_numeric($args['bid']) || !isset($args['content']) || !isset($args['title']) || !isset($args['description']) || !isset($args['language']) || !isset($args['collapsable']) || !isset($args['defaultstate'])) {
         return LogUtil::registerArgsError();
     }
     $block = DBUtil::selectObjectByID('blocks', $args['bid'], 'bid');
     // Security check
     // this function is called durung the init process so we have to check in _ZINSTALLVER
     // is set as alternative to the correct permission check
     if (!System::isInstalling() && !SecurityUtil::checkPermission('Blocks::', "{$block['bkey']}:{$block['title']}:{$block['bid']}", ACCESS_EDIT)) {
         return LogUtil::registerPermissionError();
     }
     $item = array('bid' => isset($args['bid']) ? $args['bid'] : $block['bid'], 'content' => isset($args['content']) ? $args['content'] : $block['content'], 'title' => isset($args['title']) ? $args['title'] : $block['title'], 'description' => isset($args['description']) ? $args['description'] : $block['description'], 'filter' => isset($args['filter']) ? serialize($args['filter']) : $block['filter'], 'url' => isset($args['url']) ? $args['url'] : $block['url'], 'refresh' => isset($args['refresh']) ? $args['refresh'] : $block['refresh'], 'language' => isset($args['language']) ? $args['language'] : $block['language'], 'collapsable' => isset($args['collapsable']) ? $args['collapsable'] : $block['collapsable'], 'defaultstate' => isset($args['defaultstate']) ? $args['defaultstate'] : $block['defaultstate']);
     $res = DBUtil::updateObject($item, 'blocks', '', 'bid');
     if (!$res) {
         return LogUtil::registerError($this->__('Error! Could not save your changes.'));
     }
     // leave unchanged positions as is, delete removed positions from placements table
     // and add placement for new positions
     if (isset($args['positions'])) {
         // Get all existing block positions. We do not use the userapi function here because we need
         // an associative array for the next steps: key = pid (position id)
         $allblockspositions = DBUtil::selectObjectArray('block_positions', null, 'pid', -1, -1, 'pid', null);
         foreach ($allblockspositions as $positionid => $blockposition) {
             if (in_array($positionid, $args['positions'])) {
                 // position name is present in the array submitted from the user
                 $where = "WHERE pid = '" . DataUtil::formatForStore($positionid) . '\'';
                 $blocksinposition = DBUtil::selectObjectArray('block_placements', $where, 'sortorder', -1, -1, 'bid');
                 if (array_key_exists($item['bid'], $blocksinposition)) {
                     // block is already in this position, placement did not change, this means we do nothing
                 } else {
                     // add the block to the given position as last entry (max(sortorder) +1
                     $newplacement = array('pid' => $blockposition['pid'], 'bid' => $item['bid'], 'order' => count($blocksinpositions));
                     $res = DBUtil::insertObject($newplacement, 'block_placements', 'bid', true);
                     if (!$res) {
                         return LogUtil::registerError($this->__('Error! Could not perform the insertion.'));
                     }
                 }
             } else {
                 // position name is NOT present in the array submitted from the user
                 // delete the block id from the placements table for this position
                 $where = '(bid = \'' . DataUtil::formatForStore($item['bid']) . '\' AND pid = \'' . DataUtil::formatForStore($blockposition['pid']) . '\')';
                 $res = DBUtil::deleteWhere('block_placements', $where);
                 if (!$res) {
                     return LogUtil::registerError($this->__('Error! Could not save your changes.'));
                 }
             }
         }
     }
     return true;
 }
예제 #8
0
    /**
     * Search plugin main function
     **/
    public function search($args)
    {
        if (!SecurityUtil::checkPermission('Feeds::', '::', ACCESS_READ)) {
            return true;
        }

        ModUtil::dbInfoLoad('Search');
        $pntable = DBUtil::getTables();
        $feedscolumn = $pntable['feeds_column'];
        $searchTable = $pntable['search_result'];
        $searchColumn = $pntable['search_result_column'];

        $where = search_construct_where($args,
                array($feedscolumn['name']),
                null);

        $sessionId = session_id();

        // define the permission filter to apply
        $permFilter = array(array('realm'          => 0,
                        'component_left' => 'Feeds',
                        'instance_left'  => 'fid',
                        'instance_right' => '',
                        'level'          => ACCESS_READ));

        // get the result set
        $objArray = DBUtil::selectObjectArray('feeds', $where, 'fid', 1, -1, '', $permFilter);
        if ($objArray === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }

        $insertSql =
                "INSERT INTO $searchTable
  ($searchColumn[title],
                $searchColumn[text],
                $searchColumn[extra],
                $searchColumn[created],
                $searchColumn[module],
                $searchColumn[session])
VALUES ";

        // Process the result set and insert into search result table
        foreach ($objArray as $obj) {
            $sql = $insertSql . '('
                        . '\'' . DataUtil::formatForStore($obj['name']) . '\', '
                        . '\'' . '\', '
                        . '\'' . DataUtil::formatForStore($obj['fid']) . '\', '
                        . '\'' . DataUtil::formatForStore($obj['cr_date']) . '\', '
                        . '\'' . 'Feeds' . '\', '
                        . '\'' . DataUtil::formatForStore($sessionId) . '\')';
            $insertResult = DBUtil::executeSQL($sql);
            if (!$insertResult) {
                return LogUtil::registerError(__('Error! Could not load items.', $dom));
            }
        }

        return true;
    }
예제 #9
0
 public function getDeletedPages($args)
 {
     $offset = array_key_exists('offset', $args) ? $args['offset'] : 0;
     $pageSize = array_key_exists('pageSize', $args) ? $args['pageSize'] : 20;
     $tables = DBUtil::getTables();
     $historyColumn = $tables['content_history_column'];
     $pageColumn = $tables['content_page_column'];
     $where = "{$historyColumn['pageId']} not in (select {$pageColumn['id']} from {$tables['content_page']}) and {$historyColumn['action']} = '_CONTENT_HISTORYPAGEDELETED'";
     /* related to delayed translation */
     return DBUtil::selectObjectArray('content_history', $where, 'date DESC', $offset, $pageSize);
     // TODO: distinct
 }
예제 #10
0
function mediashare_sourcesapi_getSources($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    $pntable = pnDBGetTables();
    $sourcesTable = $pntable['mediashare_sources'];
    $sourcesColumn = $pntable['mediashare_sources_column'];
    $where = "";
    if ($args['active']) {
        $where = "WHERE {$sourcesColumn['active']} = '" . DataUtil::formatForStore($args['active']) . "'";
    }
    $result = DBUtil::selectObjectArray('mediashare_sources', $where);
    if ($result === false) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.getSources', 'Could not retrieve the sources.'), $dom));
    }
    return $result;
}
예제 #11
0
파일: User.php 프로젝트: projectesIF/Sirius
    public function getall_horari($args) {
        $mdid = FormUtil::getPassedValue('mdid', isset($args['mdid']) ? $args['mdid'] : null, 'GET');

        $registres = array();
        if (!SecurityUtil::checkPermission('IWtimeframes::', '::', ACCESS_READ)) {
            return $registres;
        }

        $orderby = "start";
        $items = DBUtil::selectObjectArray('IWtimeframes', 'mdid=' . $mdid, $orderby);
        foreach ($items as $item) {
            $registres[] = array('hid' => $item['hid'],
                                 'hora' => date('H:i', strtotime($item['start'])) . " - " . date('H:i', strtotime($item['end'])),
                                 'descriu' => $item['descriu']);
        }

        //Retornem la matriu plena de registres
        return $registres;
    }
예제 #12
0
/**
 * Do the migration
 * 
 * With this function, the actual migration is done.
 * 
 * @return   boolean   true on sucessful migration, false else
 */
function EZComments_migrateapi_pnProfile()
{
    if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerError('pnProfile comments migration: Not Admin');
    }
    $columnArray = array('id', 'modname', 'objectid');
    $comments = DBUtil::selectObjectArray('EZComments', '', '', -1, -1, '', null, null, $columnArray);
    $counter = 0;
    foreach ($comments as $comment) {
        if ($comment['modname'] == 'pnProfile') {
            $comment['modname'] = 'MyProfile';
            $comment['url'] = ModUtil::url('MyProfile', 'user', 'display', array('uid' => $comment['objectid']));
            $comment['owneruid'] = $comment['objectid'];
            if (DBUtil::updateObject($comment, 'EZComments')) {
                $counter++;
            }
        }
    }
    return LogUtil::registerStatus("Updated / migrated: {$counter} comments from pnProfile to MyProfile, the successor of pnProfile");
}
예제 #13
0
파일: Admin.php 프로젝트: robbrandt/Avatar
 /**
  * get all users that use the given avatar
  *
  *@params $args['avatar']    string   the avatar name
  */
 public function getusersbyavatar($args)
 {
     if (!SecurityUtil::checkPermission('Avatar::', '::', ACCESS_READ)) {
         return LogUtil::registerPermissionError();
     }
     $users = array();
     if (!isset($args['avatar']) || empty($args['avatar'])) {
         return $users;
     }
     $ztables = DBUtil::getTables();
     $userdatacolumn = $ztables['objectdata_attributes_column'];
     if ($args['avatar'] == 'blank.gif') {
         $where = $userdatacolumn['attribute_name'] . '="avatar" AND (' . $userdatacolumn['value'] . '="' . DataUtil::formatForStore($args['avatar']) . '" OR ' . $userdatacolumn['value'] . '="")';
     } else {
         $where = $userdatacolumn['attribute_name'] . '="avatar" AND ' . $userdatacolumn['value'] . '="' . DataUtil::formatForStore($args['avatar']) . '"';
     }
     $avatarusers = DBUtil::selectObjectArray('objectdata_attributes', $where);
     foreach ($avatarusers as $avataruser) {
         $users[$avataruser['id']] = UserUtil::getVar('uname', $avataruser['object_id']);
     }
     return $users;
 }
예제 #14
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    /**
     * Performs a user search based on the user name fragment entered so far.
     *
     * Parameters passed via POST:
     * ---------------------------
     * string fragment A partial user name entered by the user.
     *
     * @return string Zikula_Response_Ajax_Plain with list of users matching the criteria.
     */
    public function getUsers()
    {
        $this->checkAjaxToken();
        $view = Zikula_View::getInstance($this->name);

        if (SecurityUtil::checkPermission('Users::', '::', ACCESS_MODERATE)) {
            $fragment = $this->request->query->get('fragment', $this->request->request->get('fragment'));

            ModUtil::dbInfoLoad($this->name);
            $tables = DBUtil::getTables();

            $usersColumn = $tables['users_column'];

            $where = 'WHERE ' . $usersColumn['uname'] . ' REGEXP \'(' . DataUtil::formatForStore($fragment) . ')\'';
            $results = DBUtil::selectObjectArray('users', $where);

            $view->assign('results', $results);
        }

        $output = $view->fetch('users_ajax_getusers.tpl');

        return new Zikula_Response_Ajax_Plain($output);
    }
예제 #15
0
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * get all pages
     *
     * @param array $args Arguments array.
     *
     * @return mixed array of items, or false on failure
     */
    public function getall($args)
    {
        // Optional arguments.
        if (!isset($args['startnum']) || empty($args['startnum'])) {
            $args['startnum'] = 0;
        }
        if (!isset($args['numitems']) || empty($args['numitems'])) {
            $args['numitems'] = -1;
        }
        if (!isset($args['ignoreml']) || !is_bool($args['ignoreml'])) {
            $args['ignoreml'] = false;
        }
        if (!isset($args['language'])) {
            $args['language'] = null;
        }
        if (!isset($args['category'])) {
            $args['category'] = null;
        }

        if (!is_numeric($args['startnum']) || !is_numeric($args['numitems'])) {
            return LogUtil::registerArgsError();
        }

        // Security check
        if (!SecurityUtil::checkPermission('Pages::', '::', ACCESS_READ)) {
            return array();
        }

        $catFilter = array();
        if (isset($args['category']) && !empty($args['category'])) {
            if (is_array($args['category'])) {
                $catFilter = $args['category'];
            } elseif (isset($args['property'])) {
                $property = $args['property'];
                $catFilter[$property] = $args['category'];
            }
            $catFilter['__META__'] = array('module' => 'Pages');
        } elseif (isset($args['catfilter'])) {
            $catFilter = $args['catfilter'];
        }

        // populate an array with each part of the where clause and then implode the array if there is a need.
        // credit to Jorg Napp for this technique - markwest
        $table = DBUtil::getTables();
        $pagescolumn = $table['pages_column'];
        $queryargs = array();
        if (System::getVar('multilingual') == 1 && !$args['ignoreml'] && $args['language']) {
            $queryargs[] = '(' . $pagescolumn['language'] . ' = "' . DataUtil::formatForStore($args['language']) . '"'
                    .' OR ' . $pagescolumn['language'] . ' = "")';
        }

        $where = null;
        if (count($queryargs) > 0) {
            $where = ' WHERE ' . implode(' AND ', $queryargs);
        }

        // define the permission filter to apply
        $permFilter   = array();
        $permFilter[] = array('component_left'  => 'Pages',
                'instance_left'   => 'title',
                'instance_right'  => 'pageid',
                'level'           => ACCESS_READ);

        $orderby = $pagescolumn['pageid'];
        if (isset($args['order']) && !empty($args['order'])) {
            $orderby = $pagescolumn[strtolower($args['order'])];
        }
        $orderdir = 'DESC';
        if (isset($args['orderdir']) && !empty($args['orderdir'])) {
            $orderdir = $args['orderdir'];
        }
        $orderby = $orderby . ' ' . $orderdir;

        // get the objects from the db
        $objArray = DBUtil::selectObjectArray(
            'pages',
            $where,
            $orderby,
            $args['startnum']-1,
            $args['numitems'],
            '',
            $permFilter,
            $catFilter
        );

        // check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($objArray === false) {
            return LogUtil::registerError($this->__('Error! Could not load any page.'));
        }

        // need to do this here as the category expansion code can't know the
        // root category which we need to build the relative path component
        if ($objArray && isset($args['catregistry']) && $args['catregistry']) {
            ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
        }

        // return the items
        return $objArray;
    }
예제 #16
0
 public function upgrade_MigrateLanguageCodes()
 {
     $objArray = DBUtil::selectObjectArray('categories_category');
     DBUtil::truncateTable('categories_category');
     $newObjArray = array();
     foreach ($objArray as $category) {
         // translate display_name l3 -> l2
         $data = unserialize($category['display_name']);
         if (is_array($data)) {
             $array = array();
             foreach ($data as $l3 => $v) {
                 $l2 = ZLanguage::translateLegacyCode($l3);
                 if ($l2) {
                     $array[$l2] = $v;
                 }
             }
             $category['display_name'] = serialize($array);
         }
         // translate display_desc l3 -> l2
         $data = unserialize($category['display_desc']);
         if (is_array($data)) {
             $array = array();
             foreach ($data as $l3 => $v) {
                 $l2 = ZLanguage::translateLegacyCode($l3);
                 if ($l2) {
                     $array[$l2] = $v;
                 }
             }
             $category['display_desc'] = serialize($array);
         }
         // commit
         DBUtil::insertObject($category, 'categories_category', 'id', true);
     }
     return;
 }
예제 #17
0
 /**
  * Update the attributes for the given objects.
  *
  * @param array   $obj      The object whose attributes we wish to store.
  * @param string  $type     The type of the given object.
  * @param string  $idcolumn The idcolumn of the object (optional) (default='id').
  * @param boolean $force    Flag to force the attribute update.
  *
  * @todo check if the function can supersede storeObjectAttributes().
  *
  * @return boolean true/false on success/failure.
  */
 public static function updateObjectAttributes($obj, $type, $idcolumn = 'id', $force = false)
 {
     if (!$obj) {
         throw new \Exception(__f('Invalid %1$s passed to %2$s.', array('object', __CLASS__ . '::' . __FUNCTION__)));
     }
     if (!$type) {
         throw new \Exception(__f('Invalid %1$s passed to %2$s.', array('type', __CLASS__ . '::' . __FUNCTION__)));
     }
     if (!isset($obj['__ATTRIBUTES__']) || !is_array($obj['__ATTRIBUTES__'])) {
         return false;
     }
     $objID = $obj[$idcolumn];
     if (!$objID) {
         throw new \Exception(__f('Unable to determine a valid ID in object [%1$s, %2$s]', array($type, $idcolumn)));
     }
     $dbtables = DBUtil::getTables();
     $column = $dbtables['objectdata_attributes_column'];
     // select all attributes so that we can check if we have to update or insert
     // this will be an assoc array of attributes with 'attribute_name' as key
     $where = 'WHERE ' . $column['object_type'] . '=\'' . DataUtil::formatForStore($type) . '\'
                 AND ' . $column['object_id'] . '=\'' . DataUtil::formatForStore($objID) . '\'';
     $attrs = DBUtil::selectObjectArray('objectdata_attributes', $where, null, null, null, 'attribute_name');
     // process all the attribute fields
     foreach ($obj['__ATTRIBUTES__'] as $k => $v) {
         // only fill empty attributes when force
         if ($force || strlen($v)) {
             if (!array_key_exists($k, $attrs)) {
                 $newobj['attribute_name'] = $k;
                 $newobj['object_id'] = $objID;
                 $newobj['object_type'] = $type;
                 $newobj['value'] = $v;
                 DBUtil::insertObject($newobj, 'objectdata_attributes');
             } else {
                 $attrs[$k]['value'] = $v;
                 DBUtil::updateObject($attrs[$k], 'objectdata_attributes');
             }
         }
     }
     if (isset($dbtables[$type])) {
         DBUtil::flushCache($type);
     }
     return true;
 }
예제 #18
0
 private function ephemerides_upgrade_updateEphemeridesLanguages()
 {
     $obj = DBUtil::selectObjectArray('ephem');
     if (count($obj) == 0) {
         // nothing to do
         return;
     }
     foreach ($obj as $ephemerid) {
         // translate l3 -> l2
         if ($l2 = ZLanguage::translateLegacyCode($ephemerid['language'])) {
             $ephemerid['language'] = $l2;
         }
         DBUtil::updateObject($ephemerid, 'ephem', '', 'eid', true);
     }
     return true;
 }
예제 #19
0
파일: User.php 프로젝트: nmpetkov/Quotes
 /**
  * Get all Quotes
  * @author The Zikula Development Team
  * @author Greg Allan
  * @return array array containing quote id, quote, author
  */
 public function getall($args)
 {
     // security check
     if (!SecurityUtil::checkPermission('Quotes::', '::', ACCESS_READ)) {
         return array();
     }
     $where = $this->_process_args($args);
     $sort = isset($args['sort']) && $args['sort'] ? $args['sort'] : '';
     $sortdir = isset($args['sortdir']) && $args['sortdir'] ? $args['sortdir'] : 'ASC';
     if ($sort) {
         if ($sort == 'qid') {
             $sort .= ' ' . $sortdir;
         } else {
             $sort .= ' ' . $sortdir . ', qid ' . $sortdir;
         }
     } else {
         $sort = 'qid DESC';
     }
     // define the permissions filter to use
     $permFilter = array();
     $permFilter[] = array('realm' => 0, 'component_left' => 'Quotes', 'component_middle' => '', 'component_right' => '', 'instance_left' => 'author', 'instance_middle' => '', 'instance_right' => 'qid', 'level' => ACCESS_READ);
     $args['catFilter'] = array();
     if (isset($args['category']) && !empty($args['category'])) {
         if (is_array($args['category'])) {
             $args['catFilter'] = $args['category'];
         } elseif (isset($args['property'])) {
             $property = $args['property'];
             $args['catFilter'][$property] = $args['category'];
         }
         $args['catFilter']['__META__'] = array('module' => 'Quotes');
     }
     // get the object array from the db
     $objArray = DBUtil::selectObjectArray('quotes', $where, $sort, $args['startnum'], $args['numitems'], '', $permFilter, $args['catFilter']);
     // check for an error with the database code, and if so set an appropriate
     // error message and return
     if ($objArray === false) {
         return LogUtil::registerError($this->__('Error! Could not load any quotes.'));
     }
     // need to do this here as the category expansion code can't know the
     // root category which we need to build the relative path component
     if ($objArray && isset($args['catregistry']) && $args['catregistry']) {
         ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
     }
     // return the items
     return $objArray;
 }
예제 #20
0
    /**
     * Check if the group that can change roles have the correct permissions
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:	Array with the id of the group where the user will be enroled
     * @return:	True if success and false in other case
     */
    public function correctGroupPermissions($args) {
        // Security check
        if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN)) {
            throw new Zikula_Exception_Forbidden();
        }
        // Get the min sequence value
        $pos = DBUtil::selectFieldMax('group_perms', 'sequence', 'MIN') + 1;

        $pntable = & DBUtil::getTables();
        $c = $pntable['group_perms_column'];

        $where = "$c[gid] = " . ModUtil::getVar('IWmyrole', 'rolegroup') . " AND $c[component] = 'IWmyrole::' AND $c[level] = 800 AND $c[sequence] = $pos";
        // get the objects from the db
        $items = DBUtil::selectObjectArray('group_perms', $where);

        // Check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($items === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }

        // Return the items
        return $items;
    }
예제 #21
0
    /**
     * Exporta els registres de la taula seleccionada a un fitxer csv
     *      
     * 
     * @return void (carrega la plantilla per importar/exportar taules)
     */
    public function exportaTaula() {
        // Security check
        //$this->checkCsrfToken();
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN));
        if ($this->request->isPost()) {
            $taula = $this->request->request->get('taula_exp', false);
        }
        if (is_null($taula)) {
            LogUtil::registerError(__('L\'exportació de dades no és possible. No s\'ha especificat cap taula.'));            
        } else {
            $titlerow = DBUtil::getColumnsArray($taula);
            $datarows = DBUtil::selectObjectArray($taula);

            $date = date('_Ymd_Hi');
            FileUtil::exportCSV($datarows, $titlerow, ';', '"', $taula . $date . '.csv');
        
        }
        // Després de exportCSV no executa aquest redirect
        //return system::redirect(ModUtil::url('Llicencies', 'admin', 'ieTables#tabs-2'));
        $this->redirect(ModUtil::url('llicencies', 'admin', 'ieTables'));
    }
예제 #22
0
파일: DBObject.php 프로젝트: Silwereth/core
 /**
  * Select the object from the database using the specified key (and field).
  *
  * @param string $key   The record's key value (if init is a string directive).
  * @param string $field The key-field we wish to select by (optional) (default=null, reverts to this->_objField).
  * @param string $where The key-field we wish to select by (optional) (default='').
  *
  * @return array The object's data value.
  */
 public function select($key, $field = '', $where = '')
 {
     if (!$this->_objType) {
         return array();
     }
     if (!$field) {
         $field = $this->_objField;
     }
     if ((!$key || !$field) && !$where) {
         return array();
     }
     // use explicit where clause
     if ($where) {
         if ($this->_objJoin) {
             $objArray = DBUtil::selectExpandedObjectArray($this->_objType, $this->_objJoin, $where, '', -1, -1, '', $this->_objPermissionFilter, $this->_objCategoryFilter, $this->_objColumnArray);
         } else {
             $objArray = DBUtil::selectObjectArray($this->_objType, $where, '', -1, -1, '', $this->_objPermissionFilter, $this->_objCategoryFilter, $this->_objColumnArray);
         }
         if ($objArray === false) {
             $this->_objData = false;
         } else {
             if (isset($objArray[0])) {
                 $this->_objData = $objArray[0];
             } else {
                 $this->_objData = array();
             }
         }
         $this->_objKey = $where;
     } else {
         // generic key=>value lookup
         if ($this->_objJoin) {
             $this->_objData = DBUtil::selectExpandedObjectById($this->_objType, $this->_objJoin, $key, $field, $this->_objColumnArray, $this->_objPermissionFilter, $this->_objCategoryFilter);
         } else {
             $this->_objData = DBUtil::selectObjectById($this->_objType, $key, $field, $this->_objColumnArray, $this->_objPermissionFilter, $this->_objCategoryFilter);
         }
         $this->_objKey = $key;
         $this->_objField = $field;
     }
     $this->selectPostProcess();
     return $this->_objData;
 }
예제 #23
0
 function simpledisplay($args)
 {
     // security check
     if (!SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_READ)) {
         return LogUtil::registerPermissionError();
     }
     $ot = FormUtil::getPassedValue('ot', isset($args['ot']) ? $args['ot'] : 'address', 'GET');
     $id = (int) FormUtil::getPassedValue('id', isset($args['id']) ? $args['id'] : null, 'GET');
     $category = FormUtil::getPassedValue('category', 0);
     $private = FormUtil::getPassedValue('private', 0);
     unset($args);
     $lang = ZLanguage::getLanguageCode();
     if (!$id) {
         return z_exit($this->__f('Error! Invalid id [%s] received.', $id));
     }
     // get the details
     $object = new AddressBook_DBObject_Address();
     $data = $object->get($id);
     // get the custom fields
     $cus_where = "";
     $cus_sort = "cus_pos ASC";
     $cus_Array = new AddressBook_DBObject_CustomfieldArray();
     $customfields = $cus_Array->get($cus_where, $cus_sort);
     foreach ($customfields as $key => $customfield) {
         if (isset($customfield['name1']) && $customfield['name1'] && $lang != 'en') {
             $customfields[$key]['name'] = $customfield['name1'];
         }
     }
     // Labels
     $addressbook_labels = DBUtil::selectObjectArray('addressbook_labels');
     $ablabels = array();
     foreach ($addressbook_labels as $addressbook_label) {
         if (isset($addressbook_label['name1']) && $addressbook_label['name1'] && $lang != 'en') {
             $addressbook_label['name'] = $addressbook_label['name1'];
         }
         $ablabels[$addressbook_label['id']] = $addressbook_label;
     }
     $this->view->assign('address', $data);
     $this->view->assign('customfields', $customfields);
     $this->view->assign('ot', $ot);
     $this->view->assign('category', $category);
     $this->view->assign('private', $private);
     $this->view->assign('preferences', ModUtil::getVar('AddressBook'));
     $this->view->assign('lang', $lang);
     $this->view->assign('ablabels', $ablabels);
     return $this->view->fetch('user_simpledisplay.tpl');
 }
예제 #24
0
    /**
     * Purge the permalink fields in the Feeds table
     * @return bool true on success, false on failure
     */
    public function purgepermalinks($args)
    {
        // Security check
        if (!SecurityUtil::checkPermission('Feeds::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // disable categorization to do this (if enabled)
        $catenabled = ModUtil::getVar('Feeds', 'enablecategorization');
        if ($catenabled) {
            ModUtil::setVar('Feeds', 'enablecategorization', false);
            ModUtil::dbInfoLoad('Feeds', 'Feeds', true);
        }

        // get all the ID and permalink of the table
        $data = DBUtil::selectObjectArray('feeds', '', '', -1, -1, 'fid', null, null, array('fid', 'urltitle'));

        // loop the data searching for non equal permalinks
        $perma = '';
        foreach (array_keys($data) as $fid) {
            $perma = strtolower(DataUtil::formatPermalink($data[$fid]['urltitle']));
            if ($data[$fid]['urltitle'] != $perma) {
                $data[$fid]['urltitle'] = $perma;
            } else {
                unset($data[$fid]);
            }
        }

        // restore the categorization if was enabled
        if ($catenabled) {
            ModUtil::setVar('Feeds', 'enablecategorization', true);
        }

        if (empty($data)) {
            return true;
            // store the modified permalinks
        } elseif (DBUtil::updateObjectArray($data, 'feeds', 'fid')) {
            // Let the calling process know that we have finished successfully
            return true;
        } else {
            return false;
        }
    }
예제 #25
0
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * Get all previous search queries.
     *
     * @param int $args['starnum']  (optional) first item to return.
     * @param int $args['numitems'] (optional) number if items to return.
     *
     * @return array array of items, or false on failure.
     */
    public function getall($args)
    {
        // Optional arguments.
        if (!isset($args['startnum']) || !is_numeric($args['startnum'])) {
            $args['startnum'] = 1;
        }
        if (!isset($args['numitems']) || !is_numeric($args['numitems'])) {
            $args['numitems'] = -1;
        }
        if (!isset($args['sortorder']) || !in_array($args['sortorder'], array('count', 'date'))) {
            $args['sortorder'] = 'count';
        }

        $items = array();

        // Security check
        if (!SecurityUtil::checkPermission('Search::', '::', ACCESS_OVERVIEW)) {
            return $items;
        }

        // Get items
        $sort = isset($args['sortorder']) ? "ORDER BY {$args['sortorder']} DESC" : '';
        $items = DBUtil::selectObjectArray('search_stat', '', $sort, $args['startnum'] - 1, $args['numitems']);

        return $items;
    }
예제 #26
0
    /**
     * upgrade the theme module from an old version
     *
     * This function must consider all the released versions of the module!
     * If the upgrade fails at some point, it returns the last upgraded version.
     *
     * @param  string $oldVersion version number string to upgrade from
     * @return mixed  true on success, last valid version string or false if fails
     */
    public function upgrade($oldversion)
    {
        // update the table
        if (!DBUtil::changeTable('themes')) {
            return false;
        }

        switch ($oldversion) {
            case '3.1':
                $this->setVar('cssjscombine', false);
                $this->setVar('cssjscompress', false);
                $this->setVar('cssjsminify', false);
                $this->setVar('cssjscombine_lifetime', 3600);

            case '3.3':
            // convert pnRender modvars
                $pnrendervars = ModUtil::getVar('pnRender');
                foreach ($pnrendervars as $k => $v) {
                    $this->setVar('render_' . $k, $v);
                }
                // delete pnRender modvars
                ModUtil::delVar('pnRender');

                $modid = ModUtil::getIdFromName('pnRender');

                // check and update blocks
                $blocks = ModUtil::apiFunc('Blocks', 'user', 'getall', array('modid' => $modid));
                if (!empty($blocks)) {
                    $thememodid = ModUtil::getIdFromName('Theme');
                    foreach ($blocks as $block) {
                        $block->setBkey('render');
                        $block->setMid($thememodid);
                        $this->entityManager->flush();
                    }
                }

                // check and fix permissions
                $dbtable = DBUtil::getTables();
                $permscolumn = $dbtable['group_perms_column'];
                $permswhere = "WHERE $permscolumn[component] = 'pnRender:pnRenderblock:'";
                $perms = DBUtil::selectObjectArray('group_perms', $permswhere);
                if (!empty($perms)) {
                    foreach ($perms as $perm) {
                        $perm['component'] = 'Theme:Renderblock:';
                        DBUtil::updateObject($perm, 'group_perms', '', 'pid');
                    }
                }

                // Set Module pnRender 'Inactive'
                if (!ModUtil::apiFunc('Extensions', 'admin', 'setstate', array(
                'id' => $modid,
                'state' => ModUtil::STATE_INACTIVE))) {
                    return '3.3';
                }
                // Remove Module pnRender from Modulelist
                if (!ModUtil::apiFunc('Extensions', 'admin', 'remove', array(
                'id' => $modid))) {
                    return '3.3';
                }

            case '3.4':
                if (!DBUtil::changeTable('themes')) {
                    return '3.4';
                }
            case '3.4.1':
                if (!DBUtil::changeTable('themes')) {
                    return '3.4.1';
                }
                $this->setVar('enable_mobile_theme', false);
            case '3.4.2':
                // future upgrade
        }

        // Update successful
        return true;
    }
예제 #27
0
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * get all user's contacts
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @return:	An array with the users
     */
    public function getAllFriends() {

        // Security check
        if (!SecurityUtil::checkPermission('IWusers::', '::', ACCESS_READ)) {
            throw new Zikula_Exception_Forbidden();
        }

        $pntable = DBUtil::getTables();
        $c = $pntable['IWusers_friends_column'];
        $where = "$c[uid]=" . UserUtil::getVar('uid');

        $items = DBUtil::selectObjectArray('IWusers_friends', $where, '', '-1', '-1', 'fuid');
        // Check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($items === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }
        // Return the items
        return $items;
    }
예제 #28
0
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * get all feeds feeds
     * @return mixed array of items, or false on failure
     */
    public function getall($args)
    {
        // Optional arguments.
        if (!isset($args['startnum']) || !is_numeric($args['startnum'])) {
            $args['startnum'] = 0;
        }
        if (!isset($args['numitems']) || !is_numeric($args['numitems'])) {
            $args['numitems'] = -1;
        }
        if (!isset($args['category'])) {
            $args['category'] = null;
        }

        if (!is_numeric($args['startnum']) ||
                !is_numeric($args['numitems'])) {
            return LogUtil::registerArgsError();
        }

        $items = array();

        // Security check
        if (!SecurityUtil::checkPermission( 'Feeds::', '::', ACCESS_READ)) {
            return $items;
        }

        $args['catFilter'] = array();
        if (isset($args['category']) && !empty($args['category'])){
            if (is_array($args['category'])) {
                $args['catFilter'] = $args['category'];
            } elseif (isset($args['property'])) {
                $property = $args['property'];
                $args['catFilter'][$property] = $args['category'];
            }
            $args['catFilter']['__META__'] = array('module' => 'Feeds');
        }

        // define the permission filter to apply
        $permFilter = array(array('realm'           => 0,
                        'component_left'  => 'Feeds',
                        'component_right' => 'item',
                        'instance_left'   => 'name',
                        'instance_right'  => 'fid',
                        'level'           => ACCESS_READ));

        $orderby = null;
        if (!empty($args['order'])) {
            $dbtable = DBUtil::getTables();
            $feedscolumn = $dbtable['feeds_column'];
            $orderby = $feedscolumn[$args['order']].' DESC';
        }

        // get the objects from the db
        $objArray = DBUtil::selectObjectArray('feeds', '', 'fid', $args['startnum']-1, $args['numitems'], '', $permFilter, $args['catFilter']);

        if ($objArray === false) {
            return LogUtil::registerError(__('Error! Could not load any Feed.'));
        }

        // need to do this here as the category expansion code can't know the
        // root category which we need to build the relative path component
        if ($objArray && isset($args['catregistry']) && $args['catregistry']) {
            ObjectUtil::postProcessExpandedObjectArrayCategories($objArray, $args['catregistry']);
        }

        // Return the items
        return $objArray;
    }
예제 #29
0
 public function getLocks($args)
 {
     $lockName = $args['lockName'];
     $sessionId = array_key_exists('sessionId', $args) ? $args['sessionId'] : session_id();
     $this->_pageLockRequireAccess();
     $dbtable = DBUtil::getTables();
     $pageLockColumn =& $dbtable['pagelock_column'];
     $now = time();
     $where = "{$pageLockColumn['expiresDate']} < '" . DateUtil::getDatetime($now) . "'";
     DBUtil::deleteWhere('pagelock', $where);
     $where = "{$pageLockColumn['name']} = '" . DataUtil::formatForStore($lockName) . "' AND {$pageLockColumn['lockedBySessionId']} != '" . DataUtil::formatForStore($sessionId) . "'";
     $locks = DBUtil::selectObjectArray('pagelock', $where);
     $this->_pageLockReleaseAccess();
     return $locks;
 }
예제 #30
-1
파일: User.php 프로젝트: projectesIF/Sirius
    /**
     * Gets from the database all the items in the submenus
     * @author:     Albert Pï¿œrez Monfort (aperezm@xtec.cat)
     * @param:	id parent of the menu which want the submenus
     * @return:	And array with the items information
     */
    public function getAllSubMenuItems($args) {

        $values = array();

        // Security check
        if (!SecurityUtil::checkPermission('IWvhmenu::', '::', ACCESS_READ)) {
            return LogUtil::registerPermissionError();
        }

        $table = DBUtil::getTables();
        $c = $table['IWvhmenu_column'];
        $where = "$c[id_parent]=$args[id_parent] AND $c[active]=1";
        $orderby = "$c[iorder]";

        // get the objects from the db
        $items = DBUtil::selectObjectArray('IWvhmenu', $where, $orderby);

        // Check for an error with the database code, and if so set an appropriate
        // error message and return
        if ($items === false) {
            return LogUtil::registerError($this->__('Error! Could not load items.'));
        }

        // Return the items
        return $items;
    }