Beispiel #1
0
    private function addStampConf(\collection $coll)
    {
        $domprefs = new DOMDocument();
        $domprefs->loadXML($coll->get_prefs());
        $prefs = '<?xml version="1.0" encoding="UTF-8"?>
<baseprefs>
    <status>0</status>

    <stamp>
        <logo position="left" width="25%"/>
        <text size="50%">Date: <var name="date"/></text>
        <text size="50%">Record_id: <var name="record_id"/></text>';
        foreach ($coll->get_databox()->get_meta_structure() as $databox_field) {
            $name = $databox_field->get_name();
            $prefs .= '<text size="50%">' . $name . ': <field name="' . $name . '"/></text>' . "\n";
        }
        $prefs .= '</stamp>
    <caninscript>1</caninscript>
    <sugestedValues>
    </sugestedValues>
</baseprefs>';
        $newdom = new DOMDocument();
        $newdom->loadXML($prefs);
        $coll->set_prefs($newdom);
    }
 /**
  * Resets admin rights on a collection.
  *
  * @param \ACL        $acl
  * @param \collection $collection
  */
 private function doResetRightsOnCollection(\ACL $acl, \collection $collection)
 {
     $baseId = $collection->get_base_id();
     $acl->set_limits($baseId, false);
     $acl->remove_quotas_on_base($baseId);
     $acl->set_masks_on_base($baseId, '0', '0', '0', '0');
     $acl->update_rights_to_base($baseId, ['canputinalbum' => '1', 'candwnldhd' => '1', 'candwnldsubdef' => '1', 'nowatermark' => '1', 'candwnldpreview' => '1', 'cancmd' => '1', 'canadmin' => '1', 'canreport' => '1', 'canpush' => '1', 'creationdate' => '1', 'canaddrecord' => '1', 'canmodifrecord' => '1', 'candeleterecord' => '1', 'chgstatus' => '1', 'imgtools' => '1', 'manage' => '1', 'modify_struct' => '1', 'bas_modify_struct' => '1']);
 }
 /**
  * Returns true if a collection is available given a configuration.
  *
  * @param \collection $collection
  *
  * @return Boolean
  */
 public function isCollectionAvailable(\collection $collection)
 {
     if (!$this->isRestricted()) {
         return true;
     }
     $availableCollections = $this->cache->fetch('available_collections_' . $collection->get_databox()->get_sbas_id()) ?: [];
     return in_array($collection->get_base_id(), $availableCollections, true);
 }
Beispiel #4
0
 /**
  *
  * @param  collection $collection
  * @param  <type>     $ordre
  * @return appbox
  */
 public function set_collection_order(collection $collection, $ordre)
 {
     $sqlupd = "UPDATE bas SET ord = :ordre WHERE base_id = :base_id";
     $stmt = $this->get_connection()->prepare($sqlupd);
     $stmt->execute([':ordre' => $ordre, ':base_id' => $collection->get_base_id()]);
     $stmt->closeCursor();
     $collection->get_databox()->delete_data_from_cache(\databox::CACHE_COLLECTIONS);
     return $this;
 }
 /**
  * Creates a EmptyCollection task given a collection
  *
  * @param \collection $collection
  *
  * @return Task
  */
 public function createEmptyCollectionJob(\collection $collection)
 {
     $job = new EmptyCollectionJob($this->translator);
     $settings = simplexml_load_string($job->getEditor()->getDefaultSettings());
     $settings->bas_id = $collection->get_base_id();
     $task = new Task();
     $task->setName($job->getName())->setJobId($job->getJobId())->setSettings($settings->asXML())->setPeriod($job->getEditor()->getDefaultPeriod());
     $this->om->persist($task);
     $this->om->flush();
     $this->notify(NotifierInterface::MESSAGE_CREATE);
     return $task;
 }
 public function plansDatatablesAjaxHandler(Request $request)
 {
     if ($request->input('method') == "first") {
         $objModelPlan = Plan::getInstance();
         $whereForPlans = array('rawQuery' => 'status = 1 or status = 0');
         $planLists = $objModelPlan->getAllPlansWhere($whereForPlans);
         $planLists = json_decode(json_encode($planLists), true);
         $plans = new collection();
         foreach ($planLists as $aap) {
             $id = $aap['plan_id'];
             $statusClass = $aap['status'] == 1 ? 'fa fa-check-circle' : 'fa fa-times-circle';
             $color = $aap['status'] == 1 ? 'green' : 'red';
             $text = $aap['status'] == 1 ? 'Active' : 'Inactive';
             $bgcolor = $aap['status'] == 1 ? 'lightgreen' : 'lightpink';
             $plans->push(['service' => $aap['plan_name'], 'min' => $aap['min_quantity'], 'max' => $aap['max_quantity'], 'ratepk' => $aap['charge_per_unit'], 'status' => '<div class="switch" id="status" data-id="' . $id . '" style="background-color:' . $color . '" >
             <input id=' . $id . ' class="cmn-toggle cmn-toggle-yes-no" type="checkbox" style="background-color:' . $color . '">
             <label for=' . $id . ' data-text="' . $text . '"></label>
         </div>', 'edit' => '<a href="/admin/plans-list-edit/' . $aap['plan_id'] . '" class="btn btn-sm btn-warning">Edit</a>']);
         }
         return Datatables::of($plans)->make(true);
     } else {
         if ($request->input('method') == "second") {
             $planType = $request->input('planType');
             $serviceType = $request->input('serviceType');
             $objModelPlans = Plan::getInstance();
             if ($planType == 5 && $serviceType == 5) {
                 $where = array('rawQuery' => 'status = 1 or status = 0');
             } elseif ($planType == 5 && $serviceType != 5) {
                 $where = array('rawQuery' => 'plan_type IN (0,1,3,4)  and service_type=?', 'bindParams' => [$serviceType]);
             } elseif ($planType != 5 && $serviceType == 5) {
                 $where = array('rawQuery' => 'service_type IN ("R","F","T") and plan_type =?', 'bindParams' => [$planType]);
             } else {
                 $where = array('rawQuery' => 'plan_type=? and service_type=?', 'bindParams' => [$planType, $serviceType]);
             }
             $planLists = $objModelPlans->getAllPlansWhere($where);
             $planLists = json_decode(json_encode($planLists), true);
             $plans = new collection();
             foreach ($planLists as $aap) {
                 $id = $aap['plan_id'];
                 $statusClass = $aap['status'] == 1 ? 'fa fa-check-circle' : 'fa fa-times-circle';
                 $color = $aap['status'] == 1 ? 'green' : 'red';
                 $bgcolor = $aap['status'] == 1 ? 'lightgreen' : 'lightpink';
                 $plans->push(['service' => $aap['plan_name'], 'min' => $aap['min_quantity'], 'max' => $aap['max_quantity'], 'ratepk' => $aap['charge_per_unit'], 'status' => '<a href="javascript:;" id="status" class="btn btn-sm btn-raised ' . $statusClass . '" style="color:' . $color . '; background-color:' . $bgcolor . '" data-id=' . $id . ' ></a>', 'edit' => '<a href="/admin/plans-list-edit/' . $aap['plan_id'] . '" class="btn btn-sm btn-warning">Edit</a>']);
             }
             return Datatables::of($plans)->make(true);
         }
     }
 }
Beispiel #7
0
 public function apply(Application $app, Request $request)
 {
     $records = RecordsRequest::fromRequest($app, $request, false, ['candeleterecord']);
     $datas = ['success' => false, 'message' => ''];
     try {
         if (null === $request->request->get('base_id')) {
             $datas['message'] = $app->trans('Missing target collection');
             return $app->json($datas);
         }
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) {
             $datas['message'] = $app->trans("You do not have the permission to move records to %collection%", ['%collection%', \phrasea::bas_labels($request->request->get('base_id'), $app)]);
             return $app->json($datas);
         }
         try {
             $collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
         } catch (\Exception_Databox_CollectionNotFound $e) {
             $datas['message'] = $app->trans('Invalid target collection');
             return $app->json($datas);
         }
         foreach ($records as $record) {
             $record->move_to_collection($collection, $app['phraseanet.appbox']);
             if ($request->request->get("chg_coll_son") == "1") {
                 foreach ($record->get_children() as $child) {
                     if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($child->get_base_id(), 'candeleterecord')) {
                         $child->move_to_collection($collection, $app['phraseanet.appbox']);
                     }
                 }
             }
         }
         $ret = ['success' => true, 'message' => $app->trans('Records have been successfuly moved')];
     } catch (\Exception $e) {
         $ret = ['success' => false, 'message' => $app->trans('An error occured')];
     }
     return $app->json($ret);
 }
Beispiel #8
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #9
0
 public function offsetSet($key, $value)
 {
     $key = $this->filter_key($key);
     if ($key > count($this)) {
         $this->_stack = array_pad($this->_stack, $key, null);
     }
     return parent::offsetSet($key, $value);
 }
Beispiel #10
0
 /**
  * Itterate over object, build a relations, fillable and includes collection.
  *
  * @param model $object the model to iterate over
  *
  * @return array
  */
 private function includes($object)
 {
     $fillable = $object->getFillable();
     $includes = $object->getIncludes();
     $table = $object->getTable();
     $columns = $object->columns();
     $results[$table] = [];
     if (!empty($includes)) {
         foreach ($includes as $include) {
             $results[$table] = ['object' => $object, 'includes' => $this->includes(new $include())];
         }
     }
     $this->fillables->put($table, $fillable);
     $this->includes->push($table, $table);
     $this->columns->put($table, $columns);
     return $results;
 }
Beispiel #11
0
 public function getReference()
 {
     $collection = collection::forClass($this->_className)->select();
     if (null != $this->_model) {
         $this->_model->save();
     }
     $id = $this->getId();
     return \MongoDBRef::create($collection->getName(), $id, (string) $collection->db);
 }
Beispiel #12
0
 /**
 		@brief		Appends a new html string to the collection.
 		@since		2014-05-04 13:08:18
 	**/
 public function append($item)
 {
     $args = func_get_args();
     $text = @call_user_func_array('sprintf', $args);
     if ($text == '') {
         $text = $args[0];
     }
     return parent::append($text);
 }
 /**
  * Get all the Keys to Success that are Blessed Up!
  * @return array
  */
 public function blessUp()
 {
     $blessUp = [];
     foreach ($this->quotes->all() as $keys => $success) {
         if (preg_match('/\\bbless up\\b/i', $success)) {
             array_push($blessUp, $success);
         }
     }
     return $blessUp;
 }
Beispiel #14
0
function list_collection($coll, $collection_list, $nav_bar)
{
    global $collection_list_tmpl;
    global $charset;
    $collection_list_tmpl = str_replace("!!cle!!", $coll, $collection_list_tmpl);
    $collection_list_tmpl = str_replace("!!list!!", $collection_list, $collection_list_tmpl);
    $collection_list_tmpl = str_replace("!!nav_bar!!", $nav_bar, $collection_list_tmpl);
    collection::search_form();
    print pmb_bidi($collection_list_tmpl);
}
Beispiel #15
0
 private function createDB(Connection $dbConn = null, $template)
 {
     $template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $template . '-simple.xml');
     $databox = \databox::create($this->app, $dbConn, $template);
     $this->app['acl']->get($this->app['authentication']->getUser())->give_access_to_sbas([$databox->get_sbas_id()])->update_rights_to_sbas($databox->get_sbas_id(), ['bas_manage' => 1, 'bas_modify_struct' => 1, 'bas_modif_th' => 1, 'bas_chupub' => 1]);
     $collection = \collection::create($this->app, $databox, $this->app['phraseanet.appbox'], 'test', $this->app['authentication']->getUser());
     $this->app['acl']->get($this->app['authentication']->getUser())->give_access_to_base([$collection->get_base_id()]);
     $this->app['acl']->get($this->app['authentication']->getUser())->update_rights_to_base($collection->get_base_id(), ['canpush' => 1, 'cancmd' => 1, 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1, 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1, 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1, 'modify_struct' => 1, 'nowatermark' => 1]);
     foreach (['PhraseanetIndexer', 'Subdefs', 'WriteMetadata'] as $jobName) {
         $job = $this->app['task-manager.job-factory']->create($jobName);
         $this->app['manipulator.task']->create($job->getName(), $job->getJobId(), $job->getEditor()->getDefaultSettings($this->app['conf']), $job->getEditor()->getDefaultPeriod());
     }
 }
 /**
  * Constructor
  * @param object $dilps as reference
  */
 function collectionLocal(&$dilps)
 {
     /**
      * for use of $db and $db_prefix in loadImgData
      */
     parent::collection($dilps);
     $sql = 'SELECT * FROM ' . $dilps->db_prefix . 'collection where host = "local" and active = 1';
     $result = $dilps->db->Execute($sql);
     while (!$result->EOF) {
         $this->addCollId($result->fields['collectionid']);
         $result->MoveNext();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function doJob(JobData $data)
 {
     $app = $data->getApplication();
     $task = $data->getTask();
     $settings = simplexml_load_string($task->getSettings());
     $baseId = (string) $settings->base_id;
     $collection = \collection::get_from_base_id($app, $baseId);
     $collection->empty_collection(200);
     if (0 === $collection->get_record_amount()) {
         $this->stop();
         $this->dispatcher->dispatch(JobEvents::FINISHED, new JobFinishedEvent($task));
     }
 }
 private function processData(Application $app, $row, $logsql)
 {
     $databox = $app['phraseanet.appbox']->get_databox($row['sbas_id']);
     $rec = $databox->get_record($row['record_id']);
     switch ($row['action']) {
         case 'UPDATE':
             // change collection ?
             if (array_key_exists('coll', $row)) {
                 $coll = \collection::get_from_coll_id($app, $databox, $row['coll']);
                 $rec->move_to_collection($coll, $app['phraseanet.appbox']);
                 $app['phraseanet.SE']->updateRecord($rec);
                 if ($logsql) {
                     $this->log('debug', sprintf("on sbas %s move rid %s to coll %s \n", $row['sbas_id'], $row['record_id'], $coll->get_coll_id()));
                 }
             }
             // change sb ?
             if (array_key_exists('sb', $row)) {
                 $status = str_split($rec->get_status());
                 foreach (str_split(strrev($row['sb'])) as $bit => $val) {
                     if ($val == '0' || $val == '1') {
                         $status[31 - $bit] = $val;
                     }
                 }
                 $rec->set_binary_status(implode('', $status));
                 $app['phraseanet.SE']->updateRecord($rec);
                 if ($logsql) {
                     $this->log('debug', sprintf("on sbas %s set rid %s status to %s \n", $row['sbas_id'], $row['record_id'], $status));
                 }
             }
             break;
         case 'DELETE':
             if ($row['deletechildren'] && $rec->is_grouping()) {
                 foreach ($rec->get_children() as $child) {
                     $child->delete();
                     $app['phraseanet.SE']->removeRecord($child);
                     if ($logsql) {
                         $this->log('debug', sprintf("on sbas %s delete (grp child) rid %s \n", $row['sbas_id'], $child->get_record_id()));
                     }
                 }
             }
             $rec->delete();
             $app['phraseanet.SE']->removeRecord($rec);
             if ($logsql) {
                 $this->log('debug', sprintf("on sbas %s delete rid %s \n", $row['sbas_id'], $rec->get_record_id()));
             }
             break;
     }
     return $this;
 }
Beispiel #19
0
function get_io_id($id)
{
    if ($id > 0) {
        $rubrics = new collection();
        $rubrics->Load(TABLE_RUBRICATOR, false, $where);
        $rubrics = $rubrics->_collection;
        for ($i = 0; $i < count($rubrics); $i++) {
            if ($id == $rubrics[$i]->id) {
                if ($rubrics[$i]->id_io_object > 0) {
                    return $rubrics[$i]->id_io_object;
                } else {
                    if ($rubrics[$i]->id_parent > 0) {
                        return get_io_id($rubrics[$i]->id_parent);
                    } else {
                        return 0;
                    }
                }
            }
        }
        return 0;
    } else {
        return 0;
    }
}
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $databox = $this->container->findDataboxById((int) $input->getArgument('databox_id'));
     $new_collection = \collection::create($this->container, $databox, $this->container->getApplicationBox(), $input->getArgument('collname'));
     if ($new_collection && $input->getOption('base_id_rights')) {
         $query = $this->container['phraseanet.user-query'];
         $total = $query->on_base_ids([$input->getOption('base_id_rights')])->get_total();
         $n = 0;
         while ($n < $total) {
             $results = $query->limit($n, 40)->execute()->get_results();
             foreach ($results as $user) {
                 $this->container->getAclForUser($user)->duplicate_right_from_bas($input->getOption('base_id_rights'), $new_collection->get_base_id());
             }
             $n += 40;
         }
     }
     $app = $this->container;
     $this->container['manipulator.acl']->resetAdminRights($this->container['repo.users']->findAdmins());
 }
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $databox = $this->container['phraseanet.appbox']->get_databox((int) $input->getArgument('databox_id'));
     $new_collection = \collection::create($this->container, $databox, $this->container['phraseanet.appbox'], $input->getArgument('collname'));
     if ($new_collection && $input->getOption('base_id_rights')) {
         $query = new \User_Query($this->container);
         $total = $query->on_base_ids([$input->getOption('base_id_rights')])->get_total();
         $n = 0;
         while ($n < $total) {
             $results = $query->limit($n, 40)->execute()->get_results();
             foreach ($results as $user) {
                 $this->container['acl']->get($user)->duplicate_right_from_bas($input->getOption('base_id_rights'), $new_collection->get_base_id());
             }
             $n += 40;
         }
     }
     $app = $this->container;
     $this->container['manipulator.acl']->resetAdminRights($this->container['manipulator.user']->getRepository()->findAdmins());
     $this->container['dispatcher']->dispatch(PhraseaEvents::COLLECTION_CREATE, new CollectionCreateEvent($new_collection));
 }
Beispiel #22
0
 /**
  * Constructor
  */
 protected function __construct()
 {
     global $section;
     parent::__construct(__FILE__);
     // create mailer support
     $system_mailer = new ContactForm_SystemMailer($this->language);
     $smtp_mailer = new ContactForm_SmtpMailer($this->language);
     $this->registerMailer('system', $system_mailer);
     $this->registerMailer('smtp', $smtp_mailer);
     // configure SMTP mailer
     $smtp_mailer->set_server($this->settings['smtp_server'], $this->settings['smtp_port'], $this->settings['use_ssl']);
     if ($this->settings['smtp_authenticate']) {
         $smtp_mailer->set_credentials($this->settings['smtp_username'], $this->settings['smtp_password']);
     }
     // register backend
     if ($section == 'backend' && class_exists('backend')) {
         $backend = backend::getInstance();
         $contact_menu = new backend_MenuItem($this->getLanguageConstant('menu_contact'), url_GetFromFilePath($this->path . 'images/icon.svg'), 'javascript:void(0);', $level = 5);
         $contact_menu->addChild('', new backend_MenuItem($this->getLanguageConstant('menu_manage_forms'), url_GetFromFilePath($this->path . 'images/forms.svg'), window_Open('contact_forms', 600, $this->getLanguageConstant('title_forms_manage'), true, true, backend_UrlMake($this->name, 'forms_manage')), $level = 5));
         $contact_menu->addChild('', new backend_MenuItem($this->getLanguageConstant('menu_manage_templates'), url_GetFromFilePath($this->path . 'images/templates.svg'), window_Open('contact_form_templates', 550, $this->getLanguageConstant('title_templates_manage'), true, true, backend_UrlMake($this->name, 'templates_manage')), $level = 5));
         $contact_menu->addSeparator(5);
         $contact_menu->addChild('', new backend_MenuItem($this->getLanguageConstant('menu_settings'), url_GetFromFilePath($this->path . 'images/settings.svg'), window_Open('contact_form_settings', 400, $this->getLanguageConstant('title_settings'), true, true, backend_UrlMake($this->name, 'settings_show')), $level = 5));
         $contact_menu->addSeparator(5);
         $contact_menu->addChild('', new backend_MenuItem($this->getLanguageConstant('menu_submissions'), url_GetFromFilePath($this->path . 'images/submissions.svg'), window_Open('contact_form_submissions', 650, $this->getLanguageConstant('title_submissions'), true, true, backend_UrlMake($this->name, 'submissions')), $level = 5));
         $backend->addMenu($this->name, $contact_menu);
         // add backend support script
         $head_tag = head_tag::getInstance();
         $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/backend.js'), 'type' => 'text/javascript'));
         $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/backend.css'), 'rel' => 'stylesheet', 'type' => 'text/css'));
     }
     if (class_exists('collection') && $section != 'backend') {
         $collection = collection::getInstance();
         $collection->includeScript(collection::DIALOG);
         $collection->includeScript(collection::COMMUNICATOR);
     }
     if (class_exists('head_tag') && $section != 'backend') {
         $head_tag = head_tag::getInstance();
         $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/contact_form.js'), 'type' => 'text/javascript'));
         $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/contact_form.css'), 'rel' => 'stylesheet', 'type' => 'text/css'));
     }
 }
Beispiel #23
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $em = $app['orm.em'];
     $sql = "SELECT date_modif, usr_id, base_id, en_cours, refuser\n                FROM demand";
     $rsm = new ResultSetMapping();
     $rsm->addScalarResult('base_id', 'base_id');
     $rsm->addScalarResult('en_cours', 'en_cours');
     $rsm->addScalarResult('refuser', 'refuser');
     $rsm->addScalarResult('usr_id', 'usr_id');
     $rsm->addScalarResult('date_modif', 'date_modif');
     $rs = $em->createNativeQuery($sql, $rsm)->getResult();
     $n = 0;
     foreach ($rs as $row) {
         try {
             $user = $em->createQuery('SELECT PARTIAL u.{id} FROM Phraseanet:User s WHERE u.id = :id')->setParameters(['id' => $row['usr_id']])->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true)->getSingleResult();
         } catch (NoResultException $e) {
             $app['monolog']->addInfo(sprintf('Patch %s : Registration for user (%s) could not be turn into doctrine entity as user could not be found.', $this->get_release(), $row['usr_id']));
             continue;
         }
         try {
             $collection = \collection::get_from_base_id($app, $row['base_id']);
         } catch (\Exception $e) {
             $app['monolog']->addInfo(sprintf('Patch %s : Registration for user (%s) could not be turn into doctrine entity as base with id (%s) could not be found.', $this->get_release(), $row['usr_id'], $row['base_id']));
             continue;
         }
         $registration = new Registration();
         $registration->setCollection($collection);
         $registration->setUser($user);
         $registration->setPending($row['en_cours']);
         $registration->setCreated(new \DateTime($row['date_modif']));
         $registration->setRejected($row['refuser']);
         if ($n % 100 === 0) {
             $em->flush();
             $em->clear();
         }
         $n++;
     }
     $em->flush();
     $em->clear();
 }
 public function postCreateFormAction(Request $request)
 {
     $collection = \collection::get_from_base_id($this->app, $request->request->get('base_id'));
     if (!$this->getAclForUser()->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
         throw new AccessDeniedHttpException('You can not create a story on this collection');
     }
     $story = \record_adapter::createStory($this->app, $collection);
     $records = RecordsRequest::fromRequest($this->app, $request, true);
     foreach ($records as $record) {
         if ($story->hasChild($record)) {
             continue;
         }
         $story->appendChild($record);
     }
     $metadatas = [];
     foreach ($collection->get_databox()->get_meta_structure() as $meta) {
         if ($meta->get_thumbtitle()) {
             $value = $request->request->get('name');
         } else {
             continue;
         }
         $metadatas[] = ['meta_struct_id' => $meta->get_id(), 'meta_id' => null, 'value' => $value];
         break;
     }
     $story->set_metadatas($metadatas)->rebuild_subdefs();
     $storyWZ = new StoryWZ();
     $storyWZ->setUser($this->getAuthenticatedUser());
     $storyWZ->setRecord($story);
     $manager = $this->getEntityManager();
     $manager->persist($storyWZ);
     $manager->flush();
     if ($request->getRequestFormat() == 'json') {
         $data = ['success' => true, 'message' => $this->app->trans('Story created'), 'WorkZone' => $storyWZ->getId(), 'story' => ['sbas_id' => $story->get_sbas_id(), 'record_id' => $story->get_record_id()]];
         return $this->app->json($data);
     }
     return $this->app->redirectPath('prod_stories_story', ['sbas_id' => $storyWZ->getSbasId(), 'record_id' => $storyWZ->getRecordId()]);
 }
Beispiel #25
0
 /**
  * Constructor
  *
  * @return backend
  */
 protected function __construct()
 {
     global $section, $language;
     parent::__construct(__FILE__);
     // create events
     Events::register('backend', 'user-create');
     Events::register('backend', 'user-change');
     Events::register('backend', 'user-delete');
     Events::register('backend', 'user-password-change');
     // load CSS and JScript
     if (class_exists('head_tag') && $section == 'backend') {
         $head_tag = head_tag::getInstance();
         $collection = collection::getInstance();
         $collection->includeScript(collection::JQUERY);
         $collection->includeScript(collection::JQUERY_EVENT_DRAG);
         $collection->includeScript(collection::WINDOW_SYSTEM);
         if ($_SESSION['logged']) {
             $collection->includeScript(collection::JQUERY_EXTENSIONS);
             $collection->includeScript(collection::NOTEBOOK);
             $collection->includeScript(collection::SHOWDOWN);
             $collection->includeScript(collection::TOOLBAR);
         }
         $head_tag->addTag('link', array('href' => url_GetFromFilePath($this->path . 'include/backend.css'), 'rel' => 'stylesheet', 'type' => 'text/css'));
         $head_tag->addTag('script', array('src' => url_GetFromFilePath($this->path . 'include/backend.js'), 'type' => 'text/javascript'));
     }
     // add admin level menus
     if ($section == 'backend') {
         $system_menu = new backend_MenuItem($this->getLanguageConstant('menu_system'), url_GetFromFilePath($this->path . 'images/icons/16/system.svg'), 'javascript:void(0);', $level = 1);
         $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_modules'), url_GetFromFilePath($this->path . 'images/icons/16/modules.svg'), window_Open('system_modules', 610, $this->getLanguageConstant('title_modules'), true, false, backend_UrlMake($this->name, 'modules')), $level = 10));
         $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_users'), url_GetFromFilePath($this->path . 'images/icons/16/users.svg'), window_Open('system_users', 690, $this->getLanguageConstant('title_users_manager'), true, false, backend_UrlMake($this->name, 'users')), $level = 10));
         $system_menu->addSeparator(10);
         $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_change_password'), url_GetFromFilePath($this->path . 'images/icons/16/change_password.svg'), window_Open('change_password_window', 350, $this->getLanguageConstant('title_change_password'), true, false, backend_UrlMake($this->name, 'change_password')), $level = 1));
         $system_menu->addChild(null, new backend_MenuItem($this->getLanguageConstant('menu_logout'), url_GetFromFilePath($this->path . 'images/icons/16/logout.svg'), window_Open('logout_window', 350, $this->getLanguageConstant('title_logout'), true, false, backend_UrlMake($this->name, 'logout')), $level = 1));
         $this->addMenu($this->name, $system_menu);
     }
 }
Beispiel #26
0
 /**
  * Update a record with a UUID
  *
  * @param \databox $databox
  * @param array    $record
  */
 protected function updateRecordUUID(\databox $databox, array $record)
 {
     $pathfile = \p4string::addEndSlash($record['path']) . $record['file'];
     $uuid = Uuid::uuid4();
     try {
         $media = $this->app['mediavorus']->guess($pathfile);
         $collection = \collection::get_from_coll_id($this->{$app}, $databox, (int) $record['coll_id']);
         $file = new File($this->app, $media, $collection);
         $uuid = $file->getUUID(true, true);
         $sha256 = $file->getSha256();
         $this->app['monolog']->addInfo(sprintf("Upgrading record %d with uuid %s", $record['record_id'], $uuid));
     } catch (\Exception $e) {
         $this->app['monolog']->addError(sprintf("Uuid upgrade for record %s failed", $record['record_id']));
     }
     $sql = 'UPDATE record SET uuid = :uuid, sha256 = :sha256 WHERE record_id = :record_id';
     $params = [':uuid' => $uuid, 'sha256' => $sha256, ':record_id' => $record['record_id']];
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute($params);
     $stmt->closeCursor();
 }
Beispiel #27
0
 /**
  * 采集内容
  * @param string $url    采集地址
  * @param array $config  配置参数
  * @param integer $page  分页采集模式
  */
 public static function get_content($url, $config, $page = 0)
 {
     set_time_limit(300);
     static $oldurl = array();
     $page = intval($page) ? intval($page) : 0;
     if ($html = self::get_html($url, $config)) {
         if (empty($page)) {
             //获取标题
             if ($config['title_rule']) {
                 $title_rule = self::replace_sg($config['title_rule']);
                 $data['title'] = self::replace_item(self::cut_html($html, $title_rule[0], $title_rule[1]), $config['title_html_rule']);
             }
             //获取作者
             if ($config['author_rule']) {
                 $author_rule = self::replace_sg($config['author_rule']);
                 $data['author'] = self::replace_item(self::cut_html($html, $author_rule[0], $author_rule[1]), $config['author_html_rule']);
             }
             //获取来源
             if ($config['comeform_rule']) {
                 $comeform_rule = self::replace_sg($config['comeform_rule']);
                 $data['comeform'] = self::replace_item(self::cut_html($html, $comeform_rule[0], $comeform_rule[1]), $config['comeform_html_rule']);
             }
             //获取时间
             if ($config['time_rule']) {
                 $time_rule = self::replace_sg($config['time_rule']);
                 $data['time'] = strtotime(self::replace_item(self::cut_html($html, $time_rule[0], $time_rule[1]), $config['time_html_rule']));
             }
             if (empty($data['time'])) {
                 $data['time'] = SYS_TIME;
             }
             //对自定义数据进行采集
             if ($config['customize_config'] = string2array($config['customize_config'])) {
                 foreach ($config['customize_config'] as $k => $v) {
                     if (empty($v['rule'])) {
                         continue;
                     }
                     $rule = self::replace_sg($v['rule']);
                     $data[$v['en_name']] = self::replace_item(self::cut_html($html, $rule[0], $rule[1]), $v['html_rule']);
                 }
             }
         }
         //获取内容
         if ($config['content_rule']) {
             $content_rule = self::replace_sg($config['content_rule']);
             $data['content'] = self::replace_item(self::cut_html($html, $content_rule[0], $content_rule[1]), $config['content_html_rule']);
         }
         //处理分页
         if (in_array($page, array(0, 2)) && !empty($config['content_page_start']) && !empty($config['content_page_end'])) {
             $oldurl[] = $url;
             $tmp[] = $data['content'];
             $page_html = self::cut_html($html, $config['content_page_start'], $config['content_page_end']);
             //上下页模式
             if ($config['content_page_rule'] == 2 && in_array($page, array(0, 2)) && $page_html) {
                 preg_match_all('/<a[^>]*href=[\'"]?([^>\'" ]*)[\'"]?[^>]*>([^<\\/]*)<\\/a>/i', $page_html, $out);
                 if (!empty($out[1]) && !empty($out[2])) {
                     foreach ($out[2] as $k => $v) {
                         if (strpos($v, $config['content_nextpage']) === false) {
                             continue;
                         }
                         if ($out[1][$k] == '#') {
                             continue;
                         }
                         $out[1][$k] = self::url_check($out[1][$k], $url, $config);
                         if (in_array($out[1][$k], $oldurl)) {
                             continue;
                         }
                         $oldurl[] = $out[1][$k];
                         $results = self::get_content($out[1][$k], $config, 2);
                         if (!in_array($results['content'], $tmp)) {
                             $tmp[] = $results['content'];
                         }
                     }
                 }
             }
             //全部罗列模式
             if ($config['content_page_rule'] == 1 && $page == 0 && $page_html) {
                 preg_match_all('/<a[^>]*href=[\'"]?([^>\'" ]*)[\'"]?/i', $page_html, $out);
                 if (is_array($out[1]) && !empty($out[1])) {
                     $out = array_unique($out[1]);
                     foreach ($out as $k => $v) {
                         if ($out[1][$k] == '#') {
                             continue;
                         }
                         $v = self::url_check($v, $url, $config);
                         $results = self::get_content($v, $config, 1);
                         if (!in_array($results['content'], $tmp)) {
                             $tmp[] = $results['content'];
                         }
                     }
                 }
             }
             $data['content'] = $config['content_page'] == 1 ? implode('[page]', $tmp) : implode('', $tmp);
         }
         if ($page == 0) {
             self::$url = $url;
             self::$config = $config;
             $data['content'] = preg_replace('/<img[^>]*src=[\'"]?([^>\'"\\s]*)[\'"]?[^>]*>/ie', "self::download_img('\$0', '\$1')", $data['content']);
             //下载内容中的图片到本地
             if (empty($page) && !empty($data['content']) && $config['down_attachment'] == 1) {
                 //pc_base::load_sys_class('attachment','',0);
                 //$attachment = new attachment('collection','0',get_siteid());
                 //$data['content'] = $attachment->download('content', $data['content'],$config['watermark']);
             }
         }
         return $data;
     }
 }
Beispiel #28
0
if (!ereg("[0-9]{4}-[0-9]{2}-[0-9]{2}", $pattern)) {
    $pattern_flag = false;
}
if ($pattern != '' && $pattern_flag == true) {
    $query = 'select count(*) as num from jGetMsgsEx(date(NOW()) -7, date(NOW()));';
} else {
    $query = 'select count(*) as num from jGetMsgsEx(date(NOW()) - 7, date(NOW()));';
}
//echo $query;
$db->query($query);
$all_num = $db->value[0]['num'];
$coms = array();
if ($all_num > 0) {
    if ($pattern != '' && $pattern_flag == true) {
        $query = 'SELECT * FROM jGetMsgsEx( \'' . db_class::escape_like($pattern) . '\', date(NOW()));';
    } else {
        $query = 'SELECT * FROM jGetMsgsEx( date(NOW())-7, date(NOW()))';
    }
    $db->query($query);
    $coms = $db->value;
}
$empl = new collection();
$empl->Load(TABLE_DLS, false, $where, 'name ASC');
$empl = $empl->_collection;
$cats = new collection();
$cats->Load(TABLE_OBJECTS, false, $where, 'name ASC');
$cats = $cats->_collection;
$page_break = get_page_break(SITE_URI_ROOT . $STORAGE['module'] . '/' . $STORAGE['action'] . '/', $all_num, $from, LIMIT_COMPANY_ON_PAGE, LIMIT_PAGE_ON_PAGE, $additional_vars);
include SITE_FILE_ROOT . 'template/header.php';
include SITE_FILE_ROOT . 'template/' . $STORAGE['module'] . '/view.php';
include SITE_FILE_ROOT . 'template/footer.php';
 static function import($data)
 {
     // cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes :
     //	$data['name'] 	Nom de la collection
     //	$data['parent']	id de l'éditeur parent de la collection
     //	$data['issn']	numéro ISSN de la collection
     global $dbh;
     // check sur le type de  la variable passée en paramètre
     if (!sizeof($data) || !is_array($data)) {
         // si ce n'est pas un tableau ou un tableau vide, on retourne 0
         return 0;
     }
     // check sur les éléments du tableau (data['name'] est requis).
     $long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT collection_name FROM collections limit 1"), 0);
     $data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name));
     //si on a pas d'id, on peut avoir les infos de l'éditeur
     if (!$data['parent']) {
         if ($data['publisher']) {
             //on les a, on crée l'éditeur
             $data['parent'] = editeur::import($data['publisher']);
         }
     }
     if ($data['name'] == "" || $data['parent'] == 0) {
         /* il nous faut impérativement un éditeur */
         return 0;
     }
     // préparation de la requête
     $key0 = addslashes($data['name']);
     $key1 = $data['parent'];
     $key2 = addslashes($data['issn']);
     /* vérification que l'éditeur existe bien ! */
     $query = "SELECT ed_id FROM publishers WHERE ed_id='{$key1}' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT publishers " . $query);
     }
     if (pmb_mysql_num_rows($result) == 0) {
         return 0;
     }
     /* vérification que la collection existe */
     $query = "SELECT collection_id FROM collections WHERE collection_name='{$key0}' AND collection_parent='{$key1}' LIMIT 1 ";
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't SELECT collections " . $query);
     }
     $collection = pmb_mysql_fetch_object($result);
     /* la collection existe, on retourne l'ID */
     if ($collection->collection_id) {
         return $collection->collection_id;
     }
     // id non-récupérée, il faut créer la forme.
     $query = 'INSERT INTO collections SET collection_name="' . $key0 . '", ';
     $query .= 'collection_parent="' . $key1 . '", ';
     $query .= 'collection_issn="' . $key2 . '", ';
     $query .= 'index_coll=" ' . strip_empty_words($key0) . ' ' . strip_empty_words($key2) . ' ", ';
     $query .= 'collection_comment = "' . addslashes($data['comment']) . '" ';
     $result = @pmb_mysql_query($query, $dbh);
     if (!$result) {
         die("can't INSERT into database");
     }
     $id = pmb_mysql_insert_id($dbh);
     if ($data['subcollections']) {
         for ($i = 0; $i < count($data['subcollections']); $i++) {
             $subcoll = $data['subcollections'][$i];
             $subcoll['coll_parent'] = $id;
             subcollection::import($subcoll);
         }
     }
     audit::insert_creation(AUDIT_COLLECTION, $id);
     //update authority informations
     $authority = new authority(0, $id, AUT_TABLE_COLLECTIONS);
     $authority->set_num_statut($data['statut']);
     $authority->update();
     collection::update_index($id);
     return $id;
 }
Beispiel #30
0
 /** 
  * Method called by the page module to add elements before printing
  */
 public function addElements()
 {
     global $section, $db_use, $optimize_code, $url_rewrite;
     $head_tag = head_tag::getInstance();
     $collection = collection::getInstance();
     $language_handler = MainLanguageHandler::getInstance();
     $default_language = $language_handler->getDefaultLanguage();
     $language_list = $language_handler->getLanguages(false);
     // add base url tag
     $head_tag->addTag('base', array('href' => _BASEURL));
     // add mobile menu script
     if (_MOBILE_VERSION && !in_array('mobile_menu', $this->omit_elements)) {
         $collection->includeScript(collection::MOBILE_MENU);
     }
     // content meta tags
     if (!in_array('content_type', $this->omit_elements)) {
         $head_tag->addTag('meta', array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=UTF-8'));
     }
     if (!in_array('viewport', $this->omit_elements) && _MOBILE_VERSION) {
         $head_tag->addTag('meta', array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0'));
     }
     if (!in_array('language', $this->omit_elements) && _STANDARD == 'html401') {
         $head_tag->addTag('meta', array('http-equiv' => 'Content-Language', 'content' => join(', ', $language_list)));
     }
     // add other languages if required
     if (count($language_list) > 1 && $url_rewrite && class_exists('language_menu')) {
         language_menu::getInstance()->addMeta();
     }
     // robot tags
     $head_tag->addTag('meta', array('name' => 'robots', 'content' => 'index, follow'));
     $head_tag->addTag('meta', array('name' => 'googlebot', 'content' => 'index, follow'));
     $head_tag->addTag('meta', array('name' => 'rating', 'content' => 'general'));
     if ($section != 'backend' && $section != 'backend_module' && $db_use) {
         // google analytics
         if (!empty($this->settings['analytics'])) {
             $head_tag->addGoogleAnalytics($this->settings['analytics'], $this->settings['analytics_domain'], $this->settings['analytics_version']);
         }
         // google website optimizer
         if (!empty($this->settings['optimizer'])) {
             $head_tag->addGoogleSiteOptimizer($this->settings['optimizer'], $this->settings['optimizer_key'], $this->optimizer_page, $this->optimizer_show_control);
         }
         // google webmaster tools
         if (!empty($this->settings['wm_tools'])) {
             $head_tag->addTag('meta', array('name' => 'google-site-verification', 'content' => $this->settings['wm_tools']));
         }
         // bing webmaster tools
         if (!empty($this->settings['bing_wm_tools'])) {
             $head_tag->addTag('meta', array('name' => 'msvalidate.01', 'content' => $this->settings['bing_wm_tools']));
         }
         // page description
         if ($db_use) {
             if (!is_null($this->page_description)) {
                 $value = $this->page_description;
             } else {
                 $value = $this->settings['description'];
             }
         }
         $head_tag->addTag('meta', array('name' => 'description', 'content' => $value));
     }
     // copyright
     if (!in_array('copyright', $this->omit_elements) && _STANDARD == 'html401') {
         $copyright = MainLanguageHandler::getInstance()->getText('copyright');
         $copyright = strip_tags($copyright);
         $head_tag->addTag('meta', array('name' => 'copyright', 'content' => $copyright));
     }
     // favicon
     if (file_exists(_BASEPATH . '/images/favicon.png')) {
         // regular, single size favicon
         $icon_files = array('16x16' => _BASEPATH . '/images/favicon.png');
     } else {
         if (file_exists(_BASEPATH . '/images/favicon')) {
             $icon_sizes = array(16, 32, 64);
             $icon_files = array();
             foreach ($icon_sizes as $size) {
                 $file_name = _BASEPATH . '/images/favicon/' . $size . '.png';
                 if (file_exists($file_name)) {
                     $icon_files[$size . 'x' . $size] = $file_name;
                 }
             }
         } else {
             $icon_files = array('16x16' => _BASEPATH . '/images/default_icon/16.png', '32x32' => _BASEPATH . '/images/default_icon/32.png', '64x64' => _BASEPATH . '/images/default_icon/64.png');
         }
     }
     foreach ($icon_files as $sizes => $icon) {
         $head_tag->addTag('link', array('rel' => 'icon', 'type' => 'image/png', 'sizes' => $sizes, 'href' => url_GetFromFilePath($icon)));
     }
     // add default styles and script if they exists
     $collection->includeScript(collection::JQUERY);
     if ($section != 'backend') {
         $styles = array();
         $less_style = null;
         // prepare list of files without extensions
         if (_DESKTOP_VERSION) {
             $styles = array('/styles/common.css', '/styles/main.css', '/styles/header.css', '/styles/content.css', '/styles/footer.css');
             $less_style = '/styles/main.less';
         } else {
             $styles = array('/styles/common.css', '/styles/main.css', '/styles/header_mobile.css', '/styles/content_mobile.css', '/styles/footer_mobile.css');
             $less_style = '/styles/main_mobile.less';
         }
         // include styles
         foreach ($styles as $style) {
             // check for css files
             if (file_exists(_BASEPATH . $style)) {
                 $head_tag->addTag('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => url_GetFromFilePath(_BASEPATH . $style)));
             }
         }
         // add main less file if it exists
         if (file_exists(_BASEPATH . $less_style)) {
             $head_tag->addTag('link', array('rel' => 'stylesheet/less', 'type' => 'text/css', 'href' => url_GetFromFilePath(_BASEPATH . $less_style)));
             if (!$optimize_code) {
                 $collection->includeScript(collection::LESS);
             }
         }
         // add main javascript
         if (file_exists(_BASEPATH . '/scripts/main.js')) {
             $head_tag->addTag('script', array('type' => 'text/javascript', 'src' => url_GetFromFilePath(_BASEPATH . '/scripts/main.js')));
         }
     }
 }