public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); if (!OW::getUser()->isAuthorized('yncontactimporter', 'invite')) { $this->setVisible(false); return; } //load css $cssUrl = OW::getPluginManager()->getPlugin('yncontactimporter')->getStaticCssUrl() . 'yncontactimporter.css'; OW::getDocument()->addStyleSheet($cssUrl); $limit = (int) $params->customParamList['count']; if (!$limit) { $limit = 5; } $providers = YNCONTACTIMPORTER_BOL_ProviderService::getInstance()->getAllProviders(array('limit' => $limit, 'enable' => 1)); $arr_providers = array(); foreach ($providers as $provider) { if (in_array($provider->name, array('facebook', 'twitter', 'linkedin'))) { $core = new YNCONTACTIMPORTER_CLASS_Core(); if (!$core->checkSocialBridgePlugin($provider->name)) { continue; } } $item = array(); $item['title'] = $provider->title; $item['name'] = $provider->name; $item['id'] = $provider->id; $item['logo'] = OW::getPluginManager()->getPlugin('yncontactimporter')->getStaticUrl() . "img/" . $provider->name . ".png"; $arr_providers[] = $item; } $this->assign('providers', $arr_providers); $this->assign('viewMore', OW::getRouter()->urlForRoute('yncontactimporter-import')); $this->assign('authorization', OW::getLanguage()->text('yncontactimporter', 'authorization')); $this->assign('import_your_contacts', OW::getLanguage()->text('yncontactimporter', 'import_your_contacts')); $this->assign("uploadCSVTitle", OW::getLanguage()->text('yncontactimporter', 'upload_csv_file')); //check show more $this->assign("showMore", 0); if ($limit < 9) { $this->assign("showMore", 1); } //get config $width = '30px'; $height = '30px'; $configs = OW::getConfig()->getValues('yncontactimporter'); if (isset($configs['logo_width'])) { $width = $configs['logo_width'] . "px"; } if (isset($configs['logo_height'])) { $height = $configs['logo_height'] . "px"; } $this->assign("width", $width); $this->assign("height", $height); OW::getLanguage()->importPluginLangs(OW::getPluginManager()->getPlugin('yncontactimporter')->getRootDir() . 'langs.zip', 'yncontactimporter'); }
/** * provider action */ public function provider() { $el = $this->_menu->getElement('management_providers'); if ($el) { $el->setActive(true); } $providers = YNCONTACTIMPORTER_BOL_ProviderService::getInstance()->getAllProviders(); foreach ($providers as $provider) { if (in_array($provider->name, array('facebook', 'twitter', 'linkedin'))) { $core = new YNCONTACTIMPORTER_CLASS_Core(); if (!$core->checkSocialBridgePlugin($provider->name)) { continue; } } $arr_providers[] = array('id' => $provider->id, 'title' => $provider->title, 'logo' => OW::getPluginManager()->getPlugin('yncontactimporter')->getStaticUrl() . "img/" . $provider->name . ".png", 'enable' => $provider->enable ? OW::getLanguage()->text('yncontactimporter', 'enabled') : OW::getLanguage()->text('yncontactimporter', 'disabled'), 'order' => $provider->order); } $this->assign('providers', $arr_providers); }
public function upload() { if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } if (!OW::getUser()->isAuthorized('yncontactimporter', 'invite')) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } if (OW::getRequest()->isPost()) { try { $core = new YNCONTACTIMPORTER_CLASS_Core(); $import_result = $core->uploadContactFile(); if (!$import_result['is_error']) { $contacts = $import_result['contacts']; foreach ($contacts as $email => $name) { $contacts_new[] = array('name' => $name, 'email' => $email); } $this->assign('contacts', urlencode(json_encode($contacts_new))); $this->assign('actionURL', OW::getRouter()->urlForRoute('yncontactimporter-import')); } else { OW::getFeedback()->error($import_result['error_message']); $this->redirect(OW::getRouter()->urlForRoute('yncontactimporter-import')); } } catch (Exception $e) { } } }