コード例 #1
0
 /**
  * Fetches properties for a path.
  *
  * This method received a PropFind object, which contains all the
  * information about the properties that need to be fetched.
  *
  * Ususually you would just want to call 'get404Properties' on this object,
  * as this will give you the _exact_ list of properties that need to be
  * fetched, and haven't yet.
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 public function propFind($path, PropFind $propFind)
 {
     $propertyNames = $propFind->get404Properties();
     if (!$propertyNames) {
         return;
     }
     // error_log("propFind: path($path), " . print_r($propertyNames, true));
     $cachedNodes = \CB\Cache::get('DAVNodes');
     // error_log("propFind: " . print_r($cachedNodes, true));
     $path = trim($path, '/');
     $path = str_replace('\\', '/', $path);
     // Node with $path is not in cached nodes, return
     if (!array_key_exists($path, $cachedNodes)) {
         return;
     }
     $node = $cachedNodes[$path];
     // while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
     //     $propFind->set($row['name'], $row['value']);
     // }
     foreach ($propertyNames as $prop) {
         if ($prop == '{DAV:}creationdate') {
             $dttm = new \DateTime($node['cdate']);
             // $dttm->getTimestamp()
             $propFind->set($prop, \Sabre\HTTP\Util::toHTTPDate($dttm));
         } elseif ($prop == '{urn:schemas-microsoft-com:office:office}modifiedby' or $prop == '{DAV:}getmodifiedby') {
             // This has to be revised, because the User.login differs from User.DisplayName
             // moreover, during an edit, Word will check for File Properties and we
             // tell Word that the file is modified by another user
             // $propFind->set($prop, \CB\User::getDisplayName($node['uid']));
         }
     }
 }
コード例 #2
0
ファイル: CacheTest.php プロジェクト: sebbie42/casebox
 public function tearDown()
 {
     if (!is_null($this->prevValue)) {
         Cache::set($this->cacheVarName, $this->prevValue);
     } else {
         Cache::remove($this->cacheVarName);
     }
 }
コード例 #3
0
ファイル: Base.php プロジェクト: ameliefranco/casebox
 /**
  * prepare target db or create it from barebone
  * @return void
  */
 protected function prepareTargetDb()
 {
     $cfg = $this->cfg;
     if (!empty($cfg['importSql'])) {
         Cache::set('RUN_SETUP_CFG', $this->cfg);
         $options = array('core' => $cfg['core_name'], 'sql' => $cfg['importSql']);
         include $this->binDirectory . 'core_create.php';
     }
 }
コード例 #4
0
ファイル: Session.php プロジェクト: austinvernsonger/casebox
 /**
  * session close
  * @return bool
  */
 public function close()
 {
     $rez = true;
     $this->gc($this->lifetime);
     // close database-connection
     $dbh = Cache::get('dbh');
     if (!empty($dbh)) {
         $rez = mysqli_close($dbh);
     }
     return $rez;
 }
コード例 #5
0
ファイル: Purify.php プロジェクト: sebbie42/casebox
 /**
  * purify given html value
  * @param  varchar $html
  * @param  array   $options associative array of purify library options
  * @return varchar
  */
 public static final function html($value, $options = array())
 {
     if (empty($value)) {
         return '';
     }
     static::getInstance();
     $value = Util\toUTF8String($value);
     $config = null;
     if (!empty($options)) {
         $config = \HTMLPurifier_Config::createDefault();
         foreach ($options as $k => $v) {
             $config->set($k, $v);
         }
     }
     $value = static::$purifier->purify($value, $config);
     Cache::remove('memory');
     return $value;
 }
コード例 #6
0
ファイル: Service.php プロジェクト: austinvernsonger/casebox
 /**
  * connect to solr service
  *
  * @return Apache_Solr_Service handler to solr intance
  */
 public function connect()
 {
     if (!empty($this->solr_handler)) {
         return $this->solr_handler;
     }
     $cacheCoreName = 'solr_service_' . $this->core;
     //check cache
     $this->solr_handler = Cache::get($cacheCoreName);
     if (empty($this->solr_handler)) {
         if (!class_exists('\\Apache_Solr_Service', false)) {
             require_once $this->client;
         }
         $this->solr_handler = new \Apache_Solr_Service($this->host, $this->port, $this->core);
         if (!$this->solr_handler->ping()) {
             throw new \Exception('Solr_connection_error' . $this->debugInfo(), 1);
         }
         //setting handler in cache raise errors for atomic updates
         Cache::set($cacheCoreName, $this->solr_handler);
     }
     return $this->solr_handler;
 }
コード例 #7
0
ファイル: router_functions.php プロジェクト: sebbie42/casebox
function doRpc($cdata)
{
    $API = \CB\Cache::get('ExtDirectAPI');
    if (!\CB\User::isLoged() && ($cdata['action'] != 'User' || $cdata['method'] != 'login') && !(php_sapi_name() == "cli")) {
        return array(array('type' => 'exception', 'name' => 'login', 'tid' => $cdata['tid'], 'action' => $cdata['action'], 'method' => $cdata['method'], 'result' => array('success' => false)));
    }
    try {
        if (!isset($API[$cdata['action']])) {
            throw new \Exception('Call to undefined action: ' . $cdata['action']);
        }
        $action = $cdata['action'];
        $a = $API[$action];
        doAroundCalls($a['before'], $cdata);
        $method = $cdata['method'];
        $mdef = $a['methods'][$method];
        if (!$mdef) {
            throw new \Exception("Call to undefined method: {$method} on action {$action}");
        }
        doAroundCalls($mdef['before'], $cdata);
        $r = array('type' => 'rpc', 'tid' => $cdata['tid'], 'action' => $action, 'method' => $method);
        $action = str_replace('_', '\\', $action);
        $o = new $action();
        $params = isset($cdata['data']) && is_array($cdata['data']) ? $cdata['data'] : array();
        $r['result'] = call_user_func_array(array($o, $method), $params);
        doAroundCalls($mdef['after'], $cdata, $r);
        doAroundCalls($a['after'], $cdata, $r);
    } catch (\Exception $e) {
        $r['type'] = 'exception';
        $r['result'] = array('success' => false, 'msg' => $e->getMessage());
        if (\CB\IS_DEBUG_HOST) {
            $r['where'] = $e->getTraceAsString();
        }
        //notify admin
        if (!(php_sapi_name() == "cli")) {
            @mail(Config::get('ADMIN_EMAIL'), 'Remote router exception on ' . Config::get('core_url'), var_export($r, true), 'From: ' . Config::get('SENDER_EMAIL') . "\r\n");
        }
    }
    return $r;
}
コード例 #8
0
ファイル: router.php プロジェクト: youprofit/casebox
 /**
  * catch server side errors and return json encoded exception
  * @return void
  */
 function extDirectShutdownFunction()
 {
     $data = \CB\Cache::get('ExtDirectData');
     $error = error_get_last();
     if (in_array($error['type'], array(1, 4))) {
         $data['type'] = 'exception';
         $data['result'] = array('success' => false);
         $data['msg'] = 'Internal server error.';
         if (\CB\IS_DEBUG_HOST) {
             $data['msg'] = $error['message'];
             $data['where'] = print_r(debug_backtrace(false), true);
         }
         //notify admin
         if (!(php_sapi_name() == "cli")) {
             @mail(Config::get('ADMIN_EMAIL'), 'Remote router error on ' . Config::get('core_url'), var_export($data, true), 'From: ' . Config::get('SENDER_EMAIL') . "\r\n");
         }
         echo Util\jsonEncode($data);
     }
     if (\CB\User::isLoged()) {
         \CB\User::updateLastActionTime();
     }
 }
コード例 #9
0
 public function setUp()
 {
     $this->DB = \CB\Cache::get('dbh');
 }
コード例 #10
0
/**
 * function to set translations in Cache
 */
function initTranslations()
{
    $translations = \CB\Cache::get('translations', []);
    // if already defined translations then exit
    if (!empty($translations)) {
        return;
    }
    $languages = \CB\Config::get('languages');
    // or : \CB\USER_LANGUAGE;
    /* reading main translations table from casebox database*/
    $res = DB\dbQuery('SELECT name, ' . implode(',', $languages) . '
        FROM ' . \CB\PREFIX . '_casebox.translations
        WHERE `type` < 2');
    // if ($rez = $res->fetch_all(MYSQLI_ASSOC)) {
    // foreach ($rez as &$r) {
    while ($r = $res->fetch_assoc()) {
        reset($r);
        $name = current($r);
        while ($v = next($r)) {
            $translations[key($r)][$name] = $v;
        }
        // }
    }
    $res->close();
    /* reading specific translations of core */
    $res = DB\dbQuery('SELECT *
        FROM translations
        WHERE `type` < 2');
    // if ($rez = $res->fetch_all(MYSQLI_ASSOC)) {
    //     foreach ($rez as &$r) {
    while ($r = $res->fetch_assoc()) {
        foreach ($languages as $l) {
            if (!empty($r[$l])) {
                $translations[$l][$r['name']] = $r[$l];
            }
        }
        //  }
    }
    $res->close();
    \CB\Cache::set('translations', $translations);
}
コード例 #11
0
ファイル: Client.php プロジェクト: sebbie42/casebox
 private function updateCronLastActionTime($cronId)
 {
     if (empty($cronId)) {
         return;
     }
     $cache_var_name = 'update_cron_' . $cronId;
     /* if less than 20 seconds have passed then skip updating db */
     if (\CB\Cache::exist($cache_var_name) && time() - \CB\Cache::get($cache_var_name) < 20) {
         return;
     }
     \CB\Cache::set($cache_var_name, time());
     $id = DM\Crons::toId($cronId, 'cron_id');
     if (empty($id)) {
         DM\Crons::create(array('cron_id' => $cronId, 'last_action' => 'CURRENT_TIMESTAMP'));
     } else {
         DM\Crons::update(array('id' => $id, 'last_action' => 'CURRENT_TIMESTAMP'));
     }
 }
コード例 #12
0
ファイル: Collection.php プロジェクト: ameliefranco/casebox
 /**
  * get template type by its id
  * @param  int     $templateId
  * @return varchar
  */
 public function getType($templateId)
 {
     if (!is_numeric($templateId)) {
         return null;
     }
     // check if template has been loaded
     if (!empty($this->templates[$templateId])) {
         return $this->templates[$templateId]->getData()['type'];
     }
     $var_name = 'template_type' . $templateId;
     if (!\CB\Cache::exist($var_name)) {
         $res = DB\dbQuery('SELECT `type`
             FROM templates
             WHERE id = $1', $templateId) or die(DB\dbQueryError());
         if ($r = $res->fetch_assoc()) {
             \CB\Cache::set($var_name, $r['type']);
         }
         $res->close();
     }
     return \CB\Cache::get($var_name);
 }
コード例 #13
0
ファイル: Object.php プロジェクト: ameliefranco/casebox
 /**
  * add action to log
  * @param  varchar $type
  * @param  array   $params
  * @return void
  */
 protected function logAction($type, $params = array())
 {
     if (!Cache::get('disable_logs', false) && !Config::getFlag('disableActivityLog')) {
         $params['type'] = $type;
         $obj =& $this;
         if (empty($params['new'])) {
             $params['new'] =& $this;
         } else {
             $obj =& $params['new'];
         }
         $logActionId = Log::add($params);
         $uid = User::getId();
         //add action to object sys_data
         $data = $obj->getData();
         $lastAction = $obj->getLastActionData();
         if ($lastAction['type'] != $type) {
             $lastAction = array('type' => $type, 'time' => Util\dateMysqlToISO('now'), 'users' => array());
         }
         /*$sysData = empty($data['sys_data'])
                         ? $this->getSysData()
                         : $data['sys_data'];
         
                     $lastAction = array(
                         'type' => $type
                         ,'time' => Util\dateMysqlToISO('now')
                         ,'users' => array()
                     );
         
                     if (!empty($sysData['lastAction']) &&
                         ($sysData['lastAction']['type'] == $type)
                     ) {
                         $lastAction['users'] = $sysData['lastAction']['users'];
                     } /**/
         unset($lastAction['users'][$uid]);
         $lastAction['users'][$uid] = $logActionId;
         $obj->setSysDataProperty('lastAction', $lastAction);
     }
 }
コード例 #14
0
ファイル: Search.php プロジェクト: austinvernsonger/casebox
 /**
  * method to get multiple object properties from solr
  * Multilanguage plugin works also
  *
  * @param  array | string $ids
  * @param  string         $fieldList
  * @return array          associative array of properties per id
  */
 public static function getObjects($ids, $fieldList = 'id,name')
 {
     $rez = array();
     $ids = Util\toNumericArray($ids);
     if (!empty($ids)) {
         $chunks = array_chunk($ids, 200);
         //connect or get solr service connection
         $conn = Cache::get('solr_service');
         if (empty($conn)) {
             $conn = new Solr\Service();
             Cache::set('solr_service', $conn);
         }
         //execute search
         try {
             foreach ($chunks as $chunk) {
                 $params = array('defType' => 'dismax', 'q.alt' => '*:*', 'fl' => $fieldList, 'fq' => array('id:(' . implode(' OR ', $chunk) . ')'));
                 $inputParams = array('ids' => $chunk);
                 $eventParams = array('params' => &$params, 'inputParams' => &$inputParams);
                 \CB\fireEvent('beforeSolrQuery', $eventParams);
                 $searchRez = $conn->search('', 0, 200, $params);
                 if (!empty($searchRez->response->docs)) {
                     foreach ($searchRez->response->docs as $d) {
                         $rd = array();
                         foreach ($d as $fn => $fv) {
                             $rd[$fn] = $fv;
                         }
                         $rez[$d->id] = $rd;
                     }
                 }
                 $eventParams['result'] = array('data' => &$rez);
                 \CB\fireEvent('solrQuery', $eventParams);
             }
         } catch (\Exception $e) {
             throw new \Exception("An error occured in getObjects: \n\n {$e->__toString()}");
         }
     }
     return $rez;
 }
コード例 #15
0
ファイル: User.php プロジェクト: sebbie42/casebox
 /**
  * get photo param to be added for photo urls
  * @param  $idOrData
  * @return varchar
  */
 public static function getPhotoParam($idOrData = false)
 {
     $data = array();
     if ($idOrData === false) {
         //use current logged users
         $id = static::getId();
     } elseif (is_numeric($idOrData)) {
         //id specified
         $id = $idOrData;
     } elseif (is_array($idOrData) && !empty($idOrData['id']) && is_numeric($idOrData['id'])) {
         $id = $idOrData['id'];
         $data = $idOrData;
     } else {
         return '';
     }
     $var_name = 'users[' . $id . "]['photoParam']";
     if (!Cache::exist($var_name)) {
         if (empty($data)) {
             $data = DM\Users::read($id);
         }
         $rez = '';
         $photosPath = Config::get('photos_path');
         $photoFile = $photosPath . $data['photo'];
         if (file_exists($photoFile)) {
             $rez = date('ynjGis', filemtime($photoFile));
         }
         Cache::set($var_name, $rez);
     }
     return Cache::get($var_name);
 }
コード例 #16
0
 /**
  * get display data for given ids
  * @param  varchar|array $ids
  * @return associative   array of users display data
  */
 public static function getDisplayData($ids)
 {
     $rez = array();
     $ids = Util\toNumericArray($ids);
     if (!empty($ids)) {
         $cdd = array();
         if (Cache::exist('UsersGroupsDisplayData')) {
             $cdd = Cache::get('UsersGroupsDisplayData');
         } else {
             $cdd = DataModel\UsersGroups::getDisplayData();
             Cache::set('UsersGroupsDisplayData', $cdd);
         }
         $rez = array_intersect_key($cdd, array_flip($ids));
     }
     return $rez;
 }
コード例 #17
0
ファイル: install.php プロジェクト: youprofit/casebox
    if (!file_exists($dir)) {
        if (!mkdir($dir, 0755, true)) {
            echo "Cant create directory {$dir} \n";
        }
    }
}
if (\CB\Cache::get('RUN_SETUP_INTERACTIVE_MODE')) {
    //---------- create solr symlinks for casebox config sets
    if (createSolrConfigsetsSymlinks($cfg)) {
        echo "Solr configsets symlinks created sucessfully.\n\r";
    } else {
        echo "Error creating symlinks to solr configsets.\n\r";
    }
}
//try to create log core
if (\CB\Cache::get('RUN_SETUP_INTERACTIVE_MODE')) {
    createSolrCore($cfg, 'log', 'log_');
}
//create default database (<prefix>__casebox)
echo "create Main Database:" . PHP_EOL;
createMainDatabase($cfg);
echo "\nCasebox was successfully configured on your system\n" . "you should create at least one Core to use it.\n";
//ask if new core instance needed
if (confirm('create_basic_core')) {
    $l = readParam('core_name');
    if (!empty($l)) {
        $ds = DIRECTORY_SEPARATOR;
        $options = array('core' => $l, 'sql' => \CB\APP_DIR . "install{$ds}mysql{$ds}bare_bone_core.sql");
        include $binDirectorty . 'core_create.php';
    }
}
コード例 #18
0
ファイル: Template.php プロジェクト: sebbie42/casebox
 /**
  * formats a value for display according to it's field definition
  * @param  array | int $field array of field properties or field id
  * @param  variant     $value field value to be formated
  * @param  boolean     $html  default true - format for html, otherwise format for text display
  * @return varchar     formated value
  */
 public static function formatValueForDisplay($field, $value, $html = true)
 {
     $cacheVarName = '';
     if (is_numeric($field)) {
         $field = $this->data->fields[$field];
     }
     //condition is specified for values from search templates
     $condition = null;
     if (is_array($value)) {
         if (isset($value['cond'])) {
             $condition = Template::formatConditionForDisplay($field, $value['cond'], $html) . ' ';
         }
         if (isset($value['value'])) {
             $value = $value['value'];
         } else {
             $value = null;
         }
     }
     //we'll cache scalar by default, but will exclude textual fields
     $cacheValue = is_scalar($value);
     if ($cacheValue) {
         $fid = empty($field['id']) ? $field['name'] : $field['id'];
         $cacheVarName = 'dv' . $html . '_' . $fid . '_' . $value;
         //check if value is in cache and return
         if (Cache::exist($cacheVarName)) {
             return Cache::get($cacheVarName);
         }
     }
     /*check if field is not rezerved field for usernames (cid, oid, uid, did)*/
     if (!empty($field['name']) && in_array($field['name'], array('cid', 'oid', 'uid', 'did'))) {
         $value = Util\toNumericArray($value);
         for ($i = 0; $i < sizeof($value); $i++) {
             $value[$i] = User::getDisplayName($value[$i]);
         }
         $value = implode(', ', $value);
     } else {
         switch ($field['type']) {
             case 'boolean':
             case 'checkbox':
                 $value = empty($value) ? '' : ($value < 0 ? L\get('no') : L\get('yes'));
                 break;
             case '_sex':
                 switch ($value) {
                     case 'm':
                         $value = L\get('male');
                         break;
                     case 'f':
                         $value = L\get('female');
                         break;
                     default:
                         $value = '';
                 }
                 break;
             case '_language':
                 @($value = @\CB\Config::get('language_settings')[\CB\Config::get('languages')[$value - 1]][0]);
                 break;
             case 'combo':
             case '_objects':
                 if (empty($value)) {
                     $value = '';
                     break;
                 }
                 $ids = Util\toNumericArray($value);
                 if (empty($ids)) {
                     if (empty($field['cfg']['source']) || !is_array($field['cfg']['source'])) {
                         $value = '';
                     }
                     break;
                 }
                 $value = array();
                 if (in_array(@$field['cfg']['source'], array('users', 'groups', 'usersgroups'))) {
                     $udp = UsersGroups::getDisplayData($ids);
                     foreach ($ids as $id) {
                         if (empty($udp[$id])) {
                             continue;
                         }
                         $r =& $udp[$id];
                         $label = @htmlspecialchars(Util\coalesce($r['title'], $r['name']), ENT_COMPAT);
                         if ($html) {
                             switch (@$field['cfg']['renderer']) {
                                 case 'listGreenIcons':
                                     $label = '<li class="icon-padding icon-element">' . $label . '</li>';
                                     break;
                                     // case 'listObjIcons':
                                 // case 'listObjIcons':
                                 default:
                                     $icon = empty($r['iconCls']) ? 'icon-none' : $r['iconCls'];
                                     $label = '<li class="icon-padding ' . $icon . '">' . $label . '</li>';
                                     break;
                             }
                         }
                         $value[] = $label;
                     }
                 } else {
                     $objects = \CB\Objects::getCachedObjects($ids);
                     foreach ($ids as $id) {
                         if (empty($objects[$id])) {
                             continue;
                         }
                         $obj =& $objects[$id];
                         $d = $obj->getData();
                         $label = $obj->getHtmlSafeName();
                         $pids = $d['pids'];
                         if ($html && !empty($pids)) {
                             $pids = str_replace(',', '/', $pids);
                             $linkType = empty($field['cfg']['linkType']) ? '' : 'link-type-' . $field['cfg']['linkType'];
                             $label = '<a class="click ' . $linkType . '" template_id="' . $d['template_id'] . '" path="' . $pids . '" nid="' . $id . '">' . $label . '</a>';
                         }
                         switch (@$field['cfg']['renderer']) {
                             case 'listGreenIcons':
                                 $value[] = $html ? '<li class="icon-padding icon-element">' . $label . '</li>' : $label;
                                 break;
                                 // case 'listObjIcons':
                             // case 'listObjIcons':
                             default:
                                 $icon = \CB\Browser::getIcon($d);
                                 if (empty($icon)) {
                                     $icon = 'icon-none';
                                 }
                                 $value[] = $html ? '<li class="icon-padding ' . $icon . '">' . $label . '</li>' : $label;
                                 break;
                         }
                     }
                 }
                 $value = $html ? '<ul class="clean">' . implode('', $value) . '</ul>' : implode(', ', $value);
                 break;
             case '_fieldTypesCombo':
                 $value = L\get(@static::$fieldTypeNames[$value]);
                 break;
             case 'date':
                 $value = Util\formatMysqlDate(Util\dateISOToMysql($value));
                 break;
             case 'datetime':
                 $value = Util\UTCTimeToUserTimezone($value);
                 break;
             case 'time':
                 if (empty($value)) {
                     continue;
                 }
                 $format = empty($field['format']) ? 'H:i' : $field['format'];
                 if (is_numeric($value)) {
                     $s = $value % 60;
                     $value = floor($value / 60);
                     $m = $value % 60;
                     $value = floor($value / 60);
                     if (strlen($value) < 2) {
                         $value = '0' . $value;
                     }
                     if (strlen($m) < 2) {
                         $m = '0' . $m;
                     }
                     $value .= ':' . $m;
                     if (!empty($s)) {
                         if (strlen($s) < 2) {
                             $s = '0' . $s;
                         }
                         $value .= ':' . $s;
                     }
                 } else {
                     $date = \DateTime::createFromFormat($format, $value);
                     if (is_object($date)) {
                         $value = $date->format($format);
                     }
                 }
                 break;
             case 'html':
                 $cacheValue = false;
                 // $value = trim(strip_tags($value));
                 // $value = nl2br($value);
                 break;
             case 'varchar':
             case 'memo':
             case 'text':
                 $cacheValue = false;
                 $renderers = '';
                 if (!empty($field['cfg']['linkRenderers'])) {
                     $renderers = $field['cfg']['linkRenderers'];
                 } elseif (!empty($field['cfg']['text_renderer'])) {
                     $renderers = $field['cfg']['text_renderer'];
                 }
                 $value = empty($renderers) ? nl2br(htmlspecialchars($value, ENT_COMPAT)) : nl2br(Comment::processAndFormatMessage($value), $renderers);
                 break;
             default:
                 if (is_array($value)) {
                     $cacheValue = false;
                     $value = Util\jsonEncode($value);
                 } else {
                     $value = htmlspecialchars($value, ENT_COMPAT);
                 }
         }
     }
     if ($cacheValue) {
         Cache::set($cacheVarName, $condition . $value);
     }
     return $condition . $value;
 }
コード例 #19
0
ファイル: Log.php プロジェクト: youprofit/casebox
 public static function getSolrLogConnection()
 {
     $rez = Cache::get('solr_log_connection');
     if (empty($rez)) {
         $cfg = Config::get('action_log');
         if (empty($cfg['core'])) {
             return;
         }
         $rez = new \CB\Search($cfg);
         Cache::set('solr_log_connection', $rez);
     }
     return $rez;
 }
コード例 #20
0
ファイル: CreateMenu.php プロジェクト: sebbie42/casebox
 protected static function getMenuRules()
 {
     $rez = Cache::get('CreateMenuRules', array());
     if (!empty($rez)) {
         return $rez;
     }
     $s = new Search();
     $ids = array();
     $sr = $s->query(array('fl' => 'id', 'template_types' => 'menu', 'skipSecurity' => true));
     foreach ($sr['data'] as $r) {
         $ids[] = $r['id'];
     }
     $arr = Objects::getCachedObjects($ids);
     foreach ($arr as $o) {
         $d = $o->getData()['data'];
         $rez[] = array('nids' => empty($d['node_ids']) ? array() : Util\toNumericArray($d['node_ids']), 'ntids' => empty($d['template_ids']) ? array() : Util\toNumericArray($d['template_ids']), 'ugids' => empty($d['user_group_ids']) ? array() : Util\toNumericArray($d['user_group_ids']), 'menu' => $d['menu']);
     }
     Cache::set('CreateMenuRules', $rez);
     return $rez;
 }
コード例 #21
0
ファイル: Service.php プロジェクト: noflopsquad/casebox
 /**
  * connect to solr service
  *
  * @return Apache_Solr_Service handler to solr intance
  */
 public function connect()
 {
     if (!empty($this->solr_handler)) {
         return $this->solr_handler;
     }
     $cacheCoreName = 'solr_service_' . $this->core;
     //check cache
     $this->solr_handler = Cache::get($cacheCoreName);
     if (empty($this->solr_handler)) {
         if (!class_exists('\\Apache_Solr_Service', false)) {
             require_once 'Apache/Solr/Service.php';
         }
         if (!class_exists('\\Apache_Solr_Compatibility_Solr4CompatibilityLayer', false)) {
             require_once 'Apache/Solr/Compatibility/AddDocumentXmlCreator.php';
             require_once 'Apache/Solr/Compatibility/CompatibilityLayer.php';
             require_once 'Apache/Solr/Compatibility/Solr4CompatibilityLayer.php';
         }
         $layer = new \Apache_Solr_Compatibility_Solr4CompatibilityLayer();
         $this->solr_handler = new \Apache_Solr_Service($this->host, $this->port, $this->core, false, $layer);
         if (!$this->solr_handler->ping()) {
             throw new \Exception('Solr_connection_error' . $this->debugInfo(), 1);
         }
         //setting handler in cache raise errors for atomic updates
         Cache::set($cacheCoreName, $this->solr_handler);
     }
     return $this->solr_handler;
 }
コード例 #22
0
/**
 * load config from CLI parameters and set respective FLAGS for install
 * @param array $options
 */
function cliLoadConfig($options = null)
{
    $cfg = null;
    if (empty($options)) {
        $options = cliGetAllOptions();
    }
    $configFile = cliGetConfigFile($options);
    if (!empty($configFile) && file_exists($configFile)) {
        $cfg = \CB\Config::loadConfigFile($configFile);
        if (count($cfg)) {
            \CB\Cache::set('RUN_SETUP_INTERACTIVE_MODE', false);
        }
        \CB\Cache::set('RUN_SETUP_CFG', $cfg);
        if (isset($cfg['overwrite_create_backups']) && $cfg['overwrite_create_backups'] == 'n') {
            \CB\Cache::set('RUN_SETUP_CREATE_BACKUPS', false);
        } else {
            \CB\Cache::set('RUN_SETUP_CREATE_BACKUPS', true);
        }
    } else {
        \CB\Cache::set('RUN_SETUP_CREATE_BACKUPS', true);
    }
    //define working mode
    if (!empty($cfg)) {
        // define('CB\\CB\Cache::get('RUN_SETUP_INTERACTIVE_MODE')', false);
        \CB\Cache::set('RUN_SETUP_INTERACTIVE_MODE', false);
        // $cfg = $cfg + $options['config'];
    } else {
        \CB\Cache::set('RUN_SETUP_INTERACTIVE_MODE', true);
    }
    // initialize default values in cofig if not detected
    $defaultValues = getDefaultConfigValues();
    if (is_array($cfg)) {
        $cfg = $cfg + $defaultValues;
    } else {
        $cfg = $defaultValues;
    }
    if (\CB\Util\checkKeyExists(array_keys($options), getParamPhrase())) {
        foreach ($options as $OptKey => $OptValue) {
            $cfg[$OptKey] = $OptValue;
        }
    }
    return $cfg;
}
コード例 #23
0
ファイル: Security.php プロジェクト: sebbie42/casebox
 /**
  * Check if userId (or current loged user) is an administrator
  *
  * @param  int     $userId
  * @return boolean
  */
 public static function isAdmin($userId = false)
 {
     if ($userId == false) {
         $userId = User::getId();
     }
     $var_name = 'is_admin' . $userId;
     if (!Cache::exist($var_name)) {
         Cache::set($var_name, DM\Users::getIdByName('root') == $userId);
     }
     return Cache::get($var_name);
 }
コード例 #24
0
ファイル: init.php プロジェクト: youprofit/casebox
/**
 * mark a cron as finished
 * @param  varchar $cron_id cron name
 * @return void
 */
function closeCron($cron_id, $info = 'ok')
{
    $scriptOptions = \CB\Cache::get('scriptOptions');
    if (!empty($scriptOptions['force'])) {
        return;
    }
    try {
        $QUERY = 'UPDATE crons
            SET last_end_time = CURRENT_TIMESTAMP, execution_info = $2
            WHERE cron_id = $1';
        DB\dbQuery($QUERY, array($cron_id, $info));
    } catch (Exception $exc) {
        trigger_error($QUERY . print_r(array($cron_id, $info), true) . DB\dbQueryError(), E_USER_WARNING);
    }
}
コード例 #25
0
$_SESSION['user'] = array('id' => 1, 'name' => 'system');
$site_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'httpsdocs') . DIRECTORY_SEPARATOR;
include $site_path . DIRECTORY_SEPARATOR . 'config_platform.php';
require_once 'mail_functions.php';
$cfg = Cache::get('platformConfig');
$mail_requirements = 'Mail requirements are:
    1. Subject of email : [$coreName #$nodeId] Comment: $nodeTitle ($nodePath)
    2. target nodeId should exist in the database.
    3. email address should be specified in casebox user profile.

    If at least one condition is not satisfied then the email would not be processed and deleted automatically.';
$mailServer = array();
$cfg = array();
$commonEmail = false;
// check if we have a common email server defined for all cores on this host
$platformConfig = Cache::get('platformConfig');
if (!empty($platformConfig['comments_email'])) {
    $mailServer = array('email' => $platformConfig['comments_email'], 'host' => $platformConfig['comments_host'], 'port' => $platformConfig['comments_port'], 'ssl' => in_array($platformConfig['comments_ssl'], array(true, 'true', 1, 'y', 'yes'), true), 'user' => @$platformConfig['comments_user'], 'pass' => $platformConfig['comments_pass']);
} else {
    //backward compatibile check
    $res = DB\dbQuery('SELECT `value`
        FROM casebox.config
        WHERE param = $1', 'comments_config') or die(DB\dbQueryError());
    if ($r = $res->fetch_assoc()) {
        $mailServer = Util\jsonDecode($r['value']);
    }
    $res->close();
}
// select active cores
$res = DB\dbQuery('SELECT id, name
    FROM `' . PREFIX . '_casebox`.cores
コード例 #26
0
ファイル: Objects.php プロジェクト: ameliefranco/casebox
 /**
  * get objects from cache or loads them and store in cache
  * @param  array $ids
  * @return array
  */
 public static function getCachedObjects($ids)
 {
     $ids = Util\toNumericArray($ids);
     $rez = array();
     $toLoad = array();
     foreach ($ids as $id) {
         //verify if already have cached result
         $var_name = 'Objects[' . $id . ']';
         if (\CB\Cache::exist($var_name)) {
             $rez[$id] = \CB\Cache::get($var_name);
         } else {
             $toLoad[] = $id;
         }
     }
     if (!empty($toLoad)) {
         $tc = Templates\SingletonCollection::getInstance();
         $data = DataModel\Objects::read($toLoad);
         foreach ($data as $objData) {
             $var_name = 'Objects[' . $objData['id'] . ']';
             $o = static::getCustomClassByType($tc->getType($objData['template_id']));
             if (!empty($o)) {
                 $o->setData($objData);
                 \CB\Cache::set($var_name, $o);
                 $rez[$objData['id']] = $o;
             }
         }
     }
     return $rez;
 }
コード例 #27
0
ファイル: Client.php プロジェクト: austinvernsonger/casebox
 private function updateCronLastActionTime($cron_id)
 {
     if (empty($cron_id)) {
         return;
     }
     $cache_var_name = 'update_cron_' . $cron_id;
     /* if less than 20 seconds have passed then skip updating db */
     if (\CB\Cache::exist($cache_var_name) && time() - \CB\Cache::get($cache_var_name) < 20) {
         return;
     }
     \CB\Cache::set($cache_var_name, time());
     DB\dbQuery('UPDATE crons
         SET last_action = CURRENT_TIMESTAMP
         WHERE cron_id = $1', $cron_id) or die('error updating crons last action');
 }
コード例 #28
0
ファイル: Base.php プロジェクト: sebbie42/casebox
 /**
  * get display columns for last node in active path
  * @return array
  */
 public function getDC()
 {
     $rez = array();
     $p =& $this->params;
     $ip =& $p['inputParams'];
     if (!empty($ip['query'])) {
         $dc = Config::get('search_DC');
         //its a config reference, get it from config
         if (!empty($dc) && is_scalar($dc)) {
             $dc = Config::getDCConfig($dc);
         }
         $rez['data'] = $dc;
     }
     if (empty($rez['data'])) {
         $path = Cache::get('current_path');
         if (!empty($path)) {
             $node = $path[sizeof($path) - 1];
             $rez = $node->getDC();
         }
     }
     if (!empty($ip['query'])) {
         $rez['from'] = 'search';
     }
     //apply properties for default casebox columns
     if (!empty($rez['data'])) {
         $defaults = Config::getDefaultGridColumnConfigs();
         foreach ($rez['data'] as $k => $v) {
             if (!empty($defaults[$k])) {
                 $rez['data'][$k] = array_merge($defaults[$k], $v);
             }
         }
     }
     return $rez;
 }
コード例 #29
0
ファイル: Objects.php プロジェクト: ameliefranco/casebox
 /**
  * get template type of an object
  * @param  int          $objectId
  * @return varchar|null
  */
 public static function getType($objectId)
 {
     if (!is_numeric($objectId)) {
         return null;
     }
     $var_name = 'obj_template_type' . $objectId;
     if (!Cache::exist($var_name)) {
         $tc = Templates\SingletonCollection::getInstance();
         Cache::set($var_name, $tc->getType(self::getTemplateId($objectId)));
     }
     return Cache::get($var_name);
 }
コード例 #30
0
/**
 * function to display errors in interactive mode or to raise them
 * @param  varchar $error
 * @return void
 */
function displayError($error)
{
    if (\CB\Cache::exist('RUN_SETUP_INTERACTIVE_MODE')) {
        if (\CB\Cache::get('RUN_SETUP_INTERACTIVE_MODE')) {
            showError($error);
            return;
        }
    }
    trigger_error($error, E_USER_ERROR);
}